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

Exclude first match from regex subpattern

I’m trying to match pairs of values from a string like 4284{336}1656{595}2961

I want to match 336 and 1656 as one group of two matches, 595 and 2961 as another, and never match the leading 4284.

I’m using ( (?<={) .*? (?=}) )* ([^{}]*)*, but that’s matching the 4284. Please note I’ve added spaces just to make it more readable. My working example is at https://regex101.com/r/P1kef7/1

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

How can I exclude the first group? Any one of these groups varies in length.

>Solution :

You can match the digits between the curly’s and the digits direct after it in 2 capture groups:

{(\d+)}(\d+)

Regex 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