in reply to Regex hyphen
what does $query contain? Best would be if you show us a complete script that demonstrates the problem you are having. I'd imagine you should only need half a dozen lines including print statements and initialisation to set variable values.
Update: using your "context":
use strict; use warnings; my $mystring = "This is a non-sense sentence."; my $query = "non-sense"; print $mystring =~/\b($query)\b/i ? "Matched" : "Missed";
prints Matched as expected. Again, please supply a small script (like the one above) that demonstrates the problem.
Note that there are several flavours of hyphen depending on the character set you are using. Maybe the hyphens in the two strings are actually different characters?
|
|---|