c:\> jython
Jython 2.1a1 on java1.3.1 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import re
>>> s = " Title: Ice Core Records"
>>> t = re.sub("^\(\s*\)Title", "\1Dataset_Title", s)
>>> t
' Title: Ice Core Records'
>>> t = re.sub("^(?P<ident>\s*)Title", "\g<ident>Dataset_Title", s)
>>> t
' Dataset_Title: Ice Core Records'
----- Original Message -----
From: "Chris Gokey" <cg...@gc...>
To: <jyt...@li...>
Sent: Tuesday, July 03, 2001 8:14 AM
Subject: [Jython-users] help on simple regular expression?
> Hi,
>
> I'm trying to use a regular expression that uses backreferences in python.
> Can someone tell me where I cam going wrong?
>
> [cgokey@cgokey cgokey]$ jython
> Jython 2.1a1 on java1.3.0 (JIT: jitc)
> Type "copyright", "credits" or "license" for more information.
> >>> import re
> >>> s = " Title: Ice Core Records"
> >>> s = re.sub("^(\s*)Title","\1Dataset_Title",s);
> >>> s
> '\001Dataset_Title: Ice Core Records'
> >>> print s
> Dataset_Title: Ice Core Records
> >>>
>
> It looks like it isn't using the back reference? The resulting output
> should be indented 3 spaces.
>
> Thanks,
> Chris
>
> --
> __________________________________________________
> /\ \
> \_| Christopher D. Gokey, SSAI, NASA/GCMD |
> | 18 Martin Road, Shelburne Falls, MA 01370 |
> | Phone: Voice (413) 625-8129 / FAX 208-248-9055 |
> | cg...@gc... / http://gcmd.nasa.gov |
> | ICQ #52132386, AOL IM: chrisgokey |
> | _____________________________________________|_
> \_/______________________________________________/
>
>
>
> _______________________________________________
> Jython-users mailing list
> Jyt...@li...
> http://lists.sourceforge.net/lists/listinfo/jython-users
>
|