From: Robert K. <rob...@ya...> - 2001-04-05 14:08:58
|
hi brian, thanks. shortly after sending my message i examined the regex once again and noticed that it seems to reduntant. so << \s* >> would have doen it too. the problem was, that it worked under by installation (jpython 1.1+7) and as i tried to install it under jython 2.0 it didnt work anymore. ciao robertj --- brian zimmer <bz...@zi...> wrote: > At 06:26 AM 4/5/2001 -0700, you wrote: > >hi, > > > >i am trying to compile a regex and > >on trying so i recive the following > >error: > >>>> > >File "E:\tools\jython\Lib\sre.py", line 63, in > compile > >File "E:\tools\jython\Lib\sre.py", line 104, in > >_compile > >error: nothing to repeat > >>>> > > > >does anybody has any idea what i am doing wrong > > > >here te script that creates the error > >>>> > >import re > >PYCMD = "^(\s*)?<%.*%>(\s*)?$" > >PYCMD_COMPILER = re.compile(PYCMD) > >>>> > > Here's my setup: > > Jython 2.1a1 on java1.3.0 (JIT: null) > Type "copyright", "credits" or "license" for more > information. > > I think the problem is the '?' in the expression. > It's job is 'either repeat 0 or 1' of the preceeding > RE or make the preceeding RE non-greedy. You have > it after the closing ')' which is not really a RE, > it's just a grouping clause. Try this: > > >>> import re > >>> re.compile(r"^(\s*?)<%.*%>(\s*?)$") > org.python.modules.sre.PatternObject@a0d51 > > CPython is the same: > > ActivePython 2.0, build 202 (ActiveState Tool Corp.) > based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC > 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more > information. > >>> import re > >>> re.compile(r"^(\s*?)<%.*%>(\s*?)$") > <SRE_Pattern object at 0082E9F0> > >>> re.compile(r"^(\s*)?<%.*%>(\s*)?$") > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "d:\python\cpython\2.0\lib\sre.py", line 62, > in compile > return _compile(pattern, flags) > File "d:\python\cpython\2.0\lib\sre.py", line 102, > in _compile > raise error, v # invalid expression > sre_constants.error: nothing to repeat > > I used > http://python.org/doc/current/lib/re-syntax.html as > reference. > > brian > ===== itemj http://www.itemj.com Robert Kuzelj mobil 0177 5302230 Ramonvillestr.6 tel 06039 930223 61184 Karben fax 06039 2224 __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/ |