Python regular expressions matching variables to end of line

Posted by None on Stack Overflow See other posts from Stack Overflow or by None
Published on 2010-04-26T00:14:20Z Indexed on 2010/04/26 0:23 UTC
Read the original article Hit count: 644

Filed under:
|
|
|

When you use variables (is that the correct word?) in python regular expressions like this: "blah (?P\w+)" ("value" would be the variable), how could you make the variable's value be the text after "blah " to the end of the line or to a certain character not paying any attention to the actual content of the variable. For example, this is pseudo-code for what I want:

>>> import re
>>> p = re.compile("say (?P<value>continue_until_text_after_assignment_is_recognized) endsay")
>>> m = p.match("say Hello hi yo endsay")
>>> m.group('value')
'Hello hi yo'

Note: The title is probably not understandable. That is because I didn't know how to say it. Sorry if I caused any confusion.

© Stack Overflow or respective owner

Related posts about python

Related posts about regex