Python Regex for any number of characters up to a character but not
including. Or remove character (comma)
I've exhausted myself trying to build either the right regex or just to
remove the comma from the file that I"m parsing. Essentially, I am match a
specific string, then anything that follows that string, up to the comma.
I need up to and not including the comma. I suppose I can do this either
with the regex or remove the comma further down in the code.
I'm pretty new at this, so probably basic stuff, but can't seem to find
the right thing in my searches
Here is my code:
import re
str = "FullName=TECIBW04 TECIBW04,
TargetResource=k2vFe6yPvBoEdrmrE9t3i5UE2muLVW,"
match = re.search(r'FullName=.+?,', str)
if match:
print match.group() ##'found a match'
else:
print 'ainnussin zer'
I get:
FullName=TECIBW04 TECIBW04,
Great...I'm getting back what I need (and a little extra). I actually
don't want the comma.
What's the best method to get rid of or not include that sucker?
No comments:
Post a Comment