Extract string that is delimited with constant and ends with two numbers (numbers have to be included)
Posted
by
Edmon
on Stack Overflow
See other posts from Stack Overflow
or by Edmon
Published on 2013-07-01T16:09:04Z
Indexed on
2013/07/01
16:21 UTC
Read the original article
Hit count: 224
I have a text that contains string of a following structure:
text I do not care about, persons name followed by two IDs.
I know that:
- a person's name is always preceded by
XYZ
code and that is always followed by two, space separated numbers. Name
is not always just a last name and first name. It can be multiple last or first names (think Latin american names).
So, I am looking to extract string that follows the constant XYZ
code and that is always terminated by two separate numbers.
You can say that my delimiter is XYZ
and two numbers, but numbers need to be part of the extracted value as well.
From
blah, blah XYZ names, names 122322 344322 blah blah
I want to extract:
names, names 122322 344322
Would someone please advise on the regular expression for this that would work with Python's re package.
© Stack Overflow or respective owner