PHP: regex: is hyphen a word character?
Self-tutoring about PHP and regular expressions: the tutor looks into whether hyphen is a word character.
From time to time I wonder about this — I think I knew but have forgotten. Anyway, I’ve checked today and it seems that the hyphen is not a member of the word character class in PHP. Said in another way, in PHP regex, \w doesn’t include the – character, so far as I’m aware.
Source:
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.
Leave a Reply
You must be logged in to post a comment.