Click to See Complete Forum and Search --> : How do I search a string for "^"?


mg8
12-06-2003, 10:51 AM
ereg("^",$firstTerm,$regs)

That doesn't work. I think it's because ^ is a regular expressions of some kind.

Any quick fix?

Thanks

chadypu
12-06-2003, 10:55 AM
uhhh i dont see what would be wrong with that... you could try \^...

maybe its the rest of your code thats not working?

edit-i guess he got it working

mg8
12-06-2003, 11:13 AM
Thanks chady :x

pyro
12-06-2003, 12:20 PM
Yes, if you need the regex engine to interpret a special character as a literal, you just escape it with a backslash. One thing I would recommend though - use PCRE (http://us3.php.net/manual/en/ref.pcre.php) instead of POSIX (http://us3.php.net/manual/en/ref.regex.php) regex. Perl compatible regex are much more powerful than POSIX extended.