how do i compare php string vars using regex -


i match (with regex) 2 strings ignoring fact 1 string may or may not have hyphens and/or single-quote chars (in fact ignore punctuation in both strings).

the problem both strings within php variables, not literals can however, not variables - ideas please ... possible.

for example pattern modifier /i specifies case-insensitive comparisons - there modifier ignore punctuation compare alpha-numeric strings ??

if (preg_replace("/['\-]/", '', $str1) == preg_replace("/['\-]/", '', $str2) {    ...equal... } 

basically: strip out ' , - both strings, compare resulting stripped strings. if yout want case-insensitive, strtolower(preg_replace(....)) instead.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -