
Dear all, I am using oxygen 9 for MacOS X. From time to time I have the following problems with find & replace while using regular expressions. I search for <l>(.+)(\d+)(</l>) (in a TEI-encoded verse text find numbers at the end of verse before the closing tag) and want to replace it with <l n="$2"> $1 ($2) $3 (copy the numbers as n attribute within the tag and put also before the closing tags within parentheses) Strangely, from time to time only the first digit is being copied with the replace function, although all digits are being highlighted with the search function. I have not been able to figure out when this happens. The same happens also if instead of (\d+) I use (\d{1,4}). Any ideas what is causing this and how it can be fixed? Best wishes, Notis

I've been able to duplicate this problem using the regular expression posted, using oXygen 9 on Mac OS X, using the lyrics below. (Numbered as if they were a basic program, as there are < 10 lines :-) However, I'm not sure it's a bug. I think maybe the regexp is working as advertised. The ".+" in the second parenthetical is greedy, and should grab all but the last digit, I think. To make it non-greedy use ".+?". original:
<l>(.+)(\d+)(</l>) <l n="$2"> $1 ($2) $3
possible improved version: <l>(.+?)(\d+)(</l>) <l n="$2"> $1 ($2) $3
Strangely, from time to time only the first digit is being copied with the replace function, although all digits are being highlighted with the search function.
Of course, all digits (actually, the entire <l> element) is being highlighted with the search function, no? Below ----- <lg type="test"> <note>To the tune of Weber & Rice's <title>Don't Cry for me Argentina</title></note> <l>Don't cry for me Charles Goldfarb, 10</l> <l>The truth is I do not miss them, 20</l> <l>All of those features, 30</l> <l>Because we're lazy, 40</l> <l>To save us typing, 50</l> <l>They drove us crazy. 60</l> </lg>

Yep, this really does not seem to be a bug. It was actually only the last digit that was being copied, thus the "greedy" .+ was responsible. I had solved the problem with an additional space in the reg. expression, but your solution is much more elegant. Thanks! N. On 11 Nov 2007, at 18:06, Syd Bauman wrote:
I've been able to duplicate this problem using the regular expression posted, using oXygen 9 on Mac OS X, using the lyrics below. (Numbered as if they were a basic program, as there are < 10 lines :-)
However, I'm not sure it's a bug. I think maybe the regexp is working as advertised. The ".+" in the second parenthetical is greedy, and should grab all but the last digit, I think. To make it non-greedy use ".+?".
original:
<l>(.+)(\d+)(</l>) <l n="$2"> $1 ($2) $3
possible improved version: <l>(.+?)(\d+)(</l>) <l n="$2"> $1 ($2) $3
Strangely, from time to time only the first digit is being copied with the replace function, although all digits are being highlighted with the search function.
Of course, all digits (actually, the entire <l> element) is being highlighted with the search function, no?
Below ----- <lg type="test"> <note>To the tune of Weber & Rice's <title>Don't Cry for me Argentina</title></note> <l>Don't cry for me Charles Goldfarb, 10</l> <l>The truth is I do not miss them, 20</l> <l>All of those features, 30</l> <l>Because we're lazy, 40</l> <l>To save us typing, 50</l> <l>They drove us crazy. 60</l> </lg>
_______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com http://www.oxygenxml.com/mailman/listinfo/oxygen-user
participants (2)
-
Syd Bauman
-
Toufexis Notis