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 get everything between letter word and number

I have example string like

Я, Филиппова Яна Сергеевна, 17.09.2001 года рождения

I need to extract everything between character Я, (always fixed) and before , 17.09.2001 ( not fixed, can be other date)

I expect Филиппова Яна Сергеевна as output excluding commas
I tried something like Я,(.*)17.09.2001 to match general pattern but it did not worked out

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

>Solution :

You can use the lookaround syntax:

(?<=Я, )[^,]+(?=, \d+\.\d+\.\d+)

How this works:

  • (?<=Я, ) positive lookbehind to match if there is a literal Я, (including whitespace) on the left
  • [^,]+ one or more characters that are not commas
  • (?=, \d+\.\d+\.\d+) positive lookahead to match if there is a date like string on the right side
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