Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

unusual regex expression

General discussions related to php

Moderators: macek, egami, gesf

unusual regex expression

Postby Iago » Wed Oct 03, 2012 7:23 am

Hello,
I do not understand the following regex expression: |(.*)(:)(.*)|
The "|" should be OR (between two strings), shouldn't it?
Thank you for your help!

Iago
Iago
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 03, 2012 7:07 am

Re: unusual regex expression

Postby seandisanti » Wed Oct 03, 2012 8:44 am

i usually have a hard time with regex, but this one looks straightforward. (.*) says to capture all sequential iteration of a pattern, in this case no pattern is specified so it will return everything. (:) means to capture just that character, and then back to another (.*). i believe that the pattern you've listed would return the same result as a single (.*)
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: unusual regex expression

Postby Iago » Wed Oct 03, 2012 8:56 pm

Thanks a lot!
Iago
New php-forum User
New php-forum User
 
Posts: 3
Joined: Wed Oct 03, 2012 7:07 am


Return to PHP General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.