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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -