You are here: Re: [PHP] preg_match « PHP « IT news, forums, messages
Re: [PHP] preg_match

Posted by "Richard Lynch" on 09/30/81 11:24

On Thu, August 18, 2005 2:50 pm, Jon wrote:
> preg_match_all("/Charges \s\s+ $total x (.+) /siU", $single,
> $from_invoice);

I would recommend using \\s instead of \s -- While \s doesn't have any
meaning in PHP strings, so PHP just figures you must have meant \\s

> The text has "Charges" then a variable amount of spaces a previously
> picked
> decimal number" x " (and the data I want)" "
>
> is this correct or am I missing something? It seems to work sometimes
> and
> not others and I have not quite figured out what makes it fail.
>
> The error I get is
> Warning: preg_match_all(): unknown modifier '#' in "file"

Does $single have a "#" character in it by any chance???

Ooooh. Or does $total sometimes have "/#" in it?

Imagine that $total has "#/#" in it.

Then your PRCE string turns into:
"/Charges \s\s+ #/# x (.+) /siU"
v--------^
Preg "sees" this / to end the search string, and then it sees a #
after that, and thinks you are trying to use # the way you are using
"siU" at the end.

Only # ain't a valid character in that location.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация