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: match not double quoted and with a dash in the middle

From the following string

ar-101 "ar102" ar103 "ar-104" ar-105 "ar-106"

I only want to match the words that don’t start or end with quotes and have a dash between two words. So from the string I want to match ar-101 & ar-105

This is my regex so far, but it matches the words between quotes as well

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

\b\w+[-]\w+(?<!")\b

demo

>Solution :

You’ve got it almost alright, just put your look behind at the start of the expression.

\b(?<!")\w+[-]\w+\b
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