× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Vern,

Having read through Jeffrey Friedl's most excellent book "Mastering Regular
Expressions" I guess I was thinking from some of the Perl examples, as Perl
has regular expressions a bit more built into the language.

So, in Perl you can refer to captured text later as program variables $1,
$2 etc, BUT within a string modification statement like:

$var =~ s/regex/replacement/

you still have to use the host variables $1 and not back references \1 in
the replacement.

E.g in this highly contrived example to replace Jeffs with Jeff's...

s/\b(Jeff)(s)\b/$1'$2/g

So I'd think of it as the first bit is a regular expression and follows all
of those syntactic rules, but the substitution bit is not a regular
expression, it is a replacement string into which they allow us to parse
some data captured from the preceding regular expression ( and which have
been stored for us in host variables )


I see your point, though, that if we just want some kind of "marker" to
indicate that we want to insert a variable at a certain point, you could
make the UI appear the same regardless of the underlaying implementation...

But you are right in that when you consider NFA DFA, POSIX and the way the
different languages build in REGEXP support along with escaping strings
characters etc, you have to be a bit careful.

PS if you haven't read that book I'd very highly recommend it!

best regards,
Craig

On 15 April 2016 at 11:24, Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx> wrote:

Yep Craig - I see your point - I also see how things work in TextPad, for
example, and there the standard \1 for back reference is used in both.

And don't get me started on this stuff in MS Word!!

Actually I think I was led down your path when looking at the help - help
for search string and for replacement string take me to completely
different places, different "standards", maybe, for all this.

I have a wish that applications using REGEX would use the same syntax
throughout. Of course, as my boss said the other day, "If I had a million
dollars, I'd not be sitting here and working!"

Regards
Vern


On 4/15/2016 3:23 AM, Craig Richards wrote:

Vern,

with regard to your comment:

So the marker for back reference is different for search text and for

replacement text - backslash for search, dollar-sign for replacement

My take on it would be that in the SEARCH string you are still within the
regular expression and so the standard \1 for back reference is what you
use.
However in the REPLACEMENT string, your data is in separate field in the
editor and therefore it is referenced via a host variable which some
languages reference via $1

Well, that's how I understand it :-)
Craig

On 14 April 2016 at 22:12, Vernon Hamberg <vhamberg@xxxxxxxxxxxxxxx>
wrote:

I have used back-references in the replacement text - $1 gets you the
first 1 - just tried in the search text.

This search text -

(r)[^r]+\1

got me strings that start with R and end with R and have at least 1 non-R
in between. Case-insensitive in this case - heh!

So the marker for back reference is different for search text and for
replacement text - backslash for search, dollar-sign for replacement

How crazy is that!

Vern


At least I THINK that is the syntax.

On 4/14/2016 3:32 PM, Buck Calabro wrote:


http://www.ibm.com/developerworks/rfe/execute?use_case=viewRfe&CR_ID=86909

I just finished using Notepad++ to do a regular expression scan and
replace. Again. I wonder if I'm an outlier in the RDi community, or if
others miss the ability to use back references in a regular expression?


--
This is the Rational Developer for IBM i / Websphere Development Studio
Client for System i & iSeries (WDSCI-L) mailing list
To post a message email: WDSCI-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/wdsci-l.


--
This is the Rational Developer for IBM i / Websphere Development Studio
Client for System i & iSeries (WDSCI-L) mailing list
To post a message email: WDSCI-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/wdsci-l
or email: WDSCI-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/wdsci-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.