regex - PHP preg_match question -
How can I get three words in the following string with Perl compatible regular expression?
word1 # $ Word2 # $ word3
I do not know the actual word "word1, word2 and word3" in advance, I know only the separator, which is # $.
And I can not use the word limit because I have a multibiotic encoding, which means that the string can have non-ASCII characters like umlauts, which are not recognized by the \ w control character .
Try this regular expression:
/ (\ w +) # \ $ (\ W +) # \ $ (\ w +) /
Edit to give us more information After (see comments for this answer):
/ ((?: [^ #] + | [^ $]) *) # \ $ ((: [^ #] | # [^ $]) *) # \ $ ((: [^ #] | # [^ $]) *) /
Comments
Post a Comment