RegEx issue with Round Brackets for Grouping

Bug #791649 reported by Diego Algara on 2011-06-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Scribes
Undecided
Unassigned

Bug Description

When I try to use RegEx to replace parts of data, like:

abc_xyz
rts_mno

Using:

Find: _(.*)
Replace: _\1_123

I expect:

abc_xyz_123
rts_mno_123

But instead I get:

abc_xyz_123
rts_xyz_123

Scribes keeps \1 as the first group of the whole file, instead of each the line.

Trying a different Replace rule: _\2_123

I get:

abc_\_123
rts_\_123

This is a very useful tool, please fix it.

Mystilleef (mystilleef) wrote :

What's the detail of scribes -i

Also read this to see if it fixes your problem.

https://answers.launchpad.net/scribes/+question/140128https://answers.launchpad.net/scribes/+question/140128

Output for scribes -i

========================================================
System Info: ('Linux', 'flexbook', '2.6.38-ARCH', '#1 SMP PREEMPT Mon May 23 22:02:08 CEST 2011', 'x86_64')
Python Version: 2.7.1 (r271:86832, Apr 15 2011, 12:09:10)
[GCC 4.5.2 20110127 (prerelease)]
System Byteorder: little
Python Modules: ('__builtin__', '__main__', '_ast', '_codecs', '_sre', '_symtable', '_warnings', '_weakref', 'errno', 'exceptions', 'gc', 'imp', 'marshal', 'posix', 'pwd', 'signal', 'sys', 'thread', 'xxsubtype', 'zipimport')
========================================================
Scribes Version: 0.4-dev-build954
Dbus Version: (0, 83, 1)
GTK+ Version: (2, 24, 4)
PyGTK Version: (2, 24, 0)
Psyco Not Installed
========================================================
Running Instance: 1
========================================================
Python Path: /usr/lib/python2.7/site-packages
Plugin Path: /usr/lib/scribes/GenericPlugins
Data Path: /usr/share/scribes
Executable Path: /usr/bin
========================================================

About the absolute notation, \g<n> instead of \n, it doesn't work, I get the exact same output.
All lines are replaced with the first line value.

:S

Oleg L (loleg) wrote :

Same problem here with this replacement:

123 abc
456 def

find: ^([0-9]+) (.*)$
replace: [\1, "\2"],

[123, "abc"],
[123, "abc"],

replace: [\g<1>, "\g<2>"], (as recommended in @mystilleef's link)

[123, "abc"],
[123, "abc"],

$ scribes -i
========================================================
System Info: ('Linux', 'maennerzugu', '3.11.0-19-generic', '#33-Ubuntu SMP Tue Mar 11 18:48:34 UTC 2014', 'x86_64')
Python Version: 2.7.5+ (default, Feb 27 2014, 19:37:08)
[GCC 4.8.1]
System Byteorder: little
Python Modules: ('__builtin__', '__main__', '_ast', '_bisect', '_codecs', '_collections', '_functools', '_heapq', '_io', '_locale', '_md5', '_random', '_sha', '_sha256', '_sha512', '_socket', '_sre', '_struct', '_symtable', '_warnings', '_weakref', 'array', 'binascii', 'cPickle', 'cStringIO', 'cmath', 'errno', 'exceptions', 'fcntl', 'gc', 'grp', 'imp', 'itertools', 'marshal', 'math', 'operator', 'posix', 'pwd', 'select', 'signal', 'spwd', 'strop', 'sys', 'syslog', 'thread', 'time', 'unicodedata', 'xxsubtype', 'zipimport', 'zlib')
========================================================
Scribes Version: 0.4-dev-build910
Dbus Version: (1, 2, 0)
GTK+ Version: (2, 24, 20)
PyGTK Version: (2, 24, 0)
Psyco Not Installed
========================================================
Running Instance: 1
========================================================
Python Path: /usr/lib/python2.7/dist-packages
Plugin Path: /usr/lib/scribes/GenericPlugins
Data Path: /usr/share/scribes
Executable Path: /usr/bin
========================================================

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers