regex - How can I detect laughing words in a string? -
i'm trying detect laughing words "hahahaha" , "lolololol" in string.
currently i'm using following regex:
^((.*?)|)(\b[ha]|\b[lo])(.*?)$
however, doesn't work purposes. works, matches words totally unrelated laughter, such 'kill', because looks word contains letters l, o, h, a.
how can detect laughing words (like "hahaha" or "lololol") in string?
try pattern:
\b(?:a*(?:ha)+h?|(?:l+o+)+l+)\b
or better if regex flavour support atomic groups , possessive quantifiers:
\b(?>a*+(?:ha)++h?|(?:l++o++)++l++)\b
Comments
Post a Comment