Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Match strange dash with preg_match()

I have big problems to match this character: –

It's something called a "en dash" U+2013 (according to http://www.fileformat.info/info/unicode/char/search.htm)

It's a match with - in my test environment (windows and php 5.2.11) but fails on the production servers (ubuntu and php 5.3.2). Even \x2013 fails there.

Any suggestions how to match this strange character? Or how to config php to make it work?

like image 488
Martin Avatar asked Sep 02 '25 05:09

Martin


1 Answers

You can also try use the "u" flag on the expression which makes the expression compatible with utf-8: regex pattern modifiers

so your expression would be "/[somepatter]/u"

like image 130
Kenrick Buchanan Avatar answered Sep 04 '25 19:09

Kenrick Buchanan