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

How to check data type in C++? -

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

sql server - SQL Query returns one result, does not return 0 or NULL result -