|
Posted by fsidler@nospam.gmail on 03/16/07 17:17
On Mar 16, 5:19 pm, "fie...@gmail.com" <fie...@gmail.com> wrote:
> I am working on a script to handle a search query. In some instances,
> the query could come through as "isbn:%20#############" (where %20 is
> an encoded space and the colon is optional). Basically I want to
> strip off the ISBN portion and leave just the numbers if that is the
> case.
>
> Orignally I was trying
> $value = $_GET["query"];
> if (preg_match("isbn:?%20", $value))
> {
> $isbn = preg_replace("isbn:?%20", "", $value)}
>
> else
> {
> $isbn = $value
>
> }
>
> Doesn't seem to work though. Any thoughts?
I wouldn't use regex unless really nessessary.
I assume your problem lies with the space character. Usually, the
script transforms encoded url characters back into their original
form. I suggest using a normal space char in the script, and just to
make sure, a str_replace("%20", " ", $string) in the beginning.
Navigation:
[Reply to this message]
|