preg_match basics question.
Posted
by Yo-L
on Stack Overflow
See other posts from Stack Overflow
or by Yo-L
Published on 2010-05-19T14:08:48Z
Indexed on
2010/05/19
14:30 UTC
Read the original article
Hit count: 241
Hi all. Got some trouble with my preg_match. The code.
$text = 'tel: 012 213 123. mobil: 0303 11234';
$regex_string = '/(tel|Tel|TEL)[\s|:]+(.+)[\.|\n]/';
preg_match($regex_string , $text, $match);
And I get this result in $match[2]
"012 213 123. mobil: 023 123 123"
First question. I want the regex to stop at the .(dot) but it doesent. Can someone explain to why it isnt?
Second question. preg_match uses () to get their match. Is it possible to skip the parentheses surrounding the different "Tel" and still get the same functionality?
Thnx all stackoverflow is great :D
© Stack Overflow or respective owner