Guys,I want to use regular expressions like preg_replace,preg_match,etc.
But I am poor at regular expressions.i.e.I always get confused how to write the
pattern.I got no of examples for reg.exp. .
But still I am getting confused while writing pattern.
So can anyone help me how do I write pattern or easiest way to write pattern.
Thanks a lot IP-Dope,
I started to study the first link.It helped me a lot.
But in the part ,I have studied so far,I did not get one thing.It may be
nothing for you.But I want help.
In some example the symbol '^' (caret) is used as negation.But in some examples it is used as the start of string.Like
Applying ^a to abc matches a. ^b will not match abc at all, because the b cannot be matched right after the start of the string, matched by ^.
The difference I noticed that it '^' if appears in square bracket ,it works as negation and if outside the square bracket as in above example in bold will work as start of string.
I could be wrong.But I want to confirm.
Good job, that's definitely the case. If you use the caret metachar outside a character class ([abc] for instance is a character class) it is used for the start of a string. Putting a caret inside the character class is negation.
And if your editor supports regex searching, its a great tool for setting up regexs. The editor in the above link is e. Its based on textmate from mac so its pretty sweet...but the great thing it does is has "live" searching (like firefox, as you type it highlights results) ... this makes it really easy to test regexs, just by typing what you want to match, then using the search untill you actually match it. That turned out to be the best tool for me to learn with, and now I really have no problems at all using regex patterns.