regex help using repreated groups

Posted by Chris H on Stack Overflow See other posts from Stack Overflow or by Chris H
Published on 2010-06-01T21:09:11Z Indexed on 2010/06/01 21:13 UTC
Read the original article Hit count: 125

Filed under:
|

I'm trying to match rc-update -s output in python.

m = re.match(r"^\s*(\w+)\s*\|{\s*(\w+)\s*}*$", " network | level1 level2 leveln ")

but m is always None

the hard part for me is getting the regex to match the n levels. I thought that using {}* would match the n levels, but as soon as I add the {} nothing matches.

thanks.

© Stack Overflow or respective owner

Related posts about python

Related posts about regex