Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expressions and accented characters

Status
Not open for further replies.

maxbld

Programmer
Nov 30, 2001
8
IT
Hi to everybody,

I have to verify if a query result contains an intere word or a part of it, to discriminate whether or not to consider it valid. The algorithm core is represented by the following command:

preg_match_all("/([a-z]|[A-Z]|)".$topic."([a-z]|[A-Z]|)/i", $result[$j], $content1);

As you can see it verifies if there are alfabetic characters immediatly around my topic. It does its job pretty well but when $topic contains an accented character. I.e. $topic = "probléme" won't match a string within which there is probléme due to that 'é', nevertheless if it was $topic = "probleme" it would have matched probleme into a string containing it.

It really puzzles me. Does somebody have an explanation to this behavior?

Thank you in advance for any help.

Max.
 
Oops! preg_match_all did *exactly* what it was meant to do. It was me who wasn't aware of the data that were to be matched: $result[$j] contained 'problèmes' instead of 'probléme'.

I beg your pardon for misposting... I was a little pissed off with my brain. :)

Max.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top