regex - python regular exp. with a unicode char -
I need a reg exp which will pars like something -
" 2 * 240 Pin " Where * I can have either regular star or Unicode char \ u00d7 or just an x, but it does not work:
multiple = r '^ (\ d +) \ s? X | * | \ U00d7 \ s? (\ D +) (\ w {2,4}) $ 'multiple palette = ray compile (multiple, re.i) print multipapet. Search (u'1 x 240pin '). Group () returns
multiplepat = re.compile (Multiple, again.) File "C: \ Python26 \ lib \ re.py" , Line 188, compile back _compile (pattern, flags) file "C: \ Python26 \ lib \ re.py", line 243, _compile in error, v # invalid expression error: repeat
You need to avoid * because it is the quantifier in the context in your reference. But you can also use a character class. So try:
ur '^ (\ d +) \ s? [X * \ u00d7] \ s? (\ D +) (\ w {2,4}) $ '
Comments
Post a Comment