Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regex – Find string that has 5 or more mentions in it

Trying to detect whether a message has 5 or more mentions in it. For example:

"@Boddy is doing great with @shirly @rebecca @jimmy and @mom"

Above will count as one match. This will not count as a match:

"@Boddy is doing great with @shirly @rebecca @jimmy and ..."

Preferably, "@@@@@" should not count either, but not too important!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’ve tried

@([^@ ]+){5,}

But no luck, it highlights all 5 instead of the whole string.

>Solution :

Use a pattern which covers the entire string:

^.*@.*@.*@.*@.*@.*$

Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading