Showing posts with label Regular Expressions PHP Tutorial. Show all posts
Showing posts with label Regular Expressions PHP Tutorial. Show all posts
Regular expression Basics in php
Posted by Raj
Regular expression Basics in php:
In this article ,i will show how to use regular expressions in php.
\char escape char
. Any single character
[chars] One of following chars
[^chars] None of following chars
text1|text2 text1 or text2
? 0 or 1 of the preceding text
* 0 or N of the preceding text (hungry)
+ 1 or N of the preceding text
Example: (.+)\.html? matches test.htm and test.html
(text) Grouping of text
Example: ^(.*)\.html foo.php?bar=$1
^ Start of line anchor
$ End of line anchor
Example: ^test(.*) matches test and test1 but not ttest
(.*)1$ matches a1 and b1, but not test
In this article ,i will show how to use regular expressions in php.
\char escape char
. Any single character
[chars] One of following chars
[^chars] None of following chars
text1|text2 text1 or text2
? 0 or 1 of the preceding text
* 0 or N of the preceding text (hungry)
+ 1 or N of the preceding text
Example: (.+)\.html? matches test.htm and test.html
(text) Grouping of text
Example: ^(.*)\.html foo.php?bar=$1
^ Start of line anchor
$ End of line anchor
Example: ^test(.*) matches test and test1 but not ttest
(.*)1$ matches a1 and b1, but not test