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

Popular posts from this blog

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

Why does PHP consider 0 to be equal to a string? -

formula - R: how to pass in a reference to the variable in glm or lm? -