Matching characters [a-zA-Z] in PHP regular expression

I have a few lines that need a-strippin ':

ÜT: 9.996636,76.294363

Tons of long lines of location codes. Literal regex in PHP won't match them, IE

$pattern = /ÜT:/;
echo preg_replace($pattern, "", $row['location']);

      

No match / stripe. (To see if it works, /T:/

strip the last bit of that line). What's going on with the coding error here?

Alternatively, I would accept a concise way to output only numbers.

+2


a source to share


2 answers


If the text is all in this format (: followed by a space), you can simply say:

$str = explode(": ", $pattern);
echo($str[1]);

      



It's not the most elegant solution and I have no idea if it's incredibly slow, but it works for most things. Unless you are inclined to use regex.

+2


a source


You need to use / u modifier for regex to work with unicode



0


a source







All Articles