February 11th, 2004, 01:59 AM
short question concering a regular expression pattern.
With this I get the following result:
line = '1 "bla \"bla\" $%1!\n" $ just "a" test'
rexEntry = re.compile('^(\d+)\s"(.*)" *(\$.*)?')
mo = rexEntry.match(line)
But that what I want is:
('1', 'bla \"bla\" $%1!\n" $ just "a', None)
Can someone give me a hint?
('1', 'bla \"bla\" $%1!\n', '$ just "a" test')
Thanks in advance!
February 11th, 2004, 03:45 AM
This works for me... with the example above.
Note: If you use this with match you shouldnt have to have the ^ at the beginning.
Hope this helps,
February 12th, 2004, 07:52 AM
Thank you for your reply.
Your code works for the example above but there are still cases in my problem that can't be matched with this pattern.
I solved the problem by specifying two patterns and combined them with |
That works now for me...
... I always use ^ if I want to find a string at the beginning. I know that just "match" will do it also but ...
... I don't know ... habit