× 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.



Hi Scott,

I'm trying to understand this too.
I changed the findWithin to 'There is none but the one or none at all.'. If
I were looking for regex matches for 'one', I would expect to find three:
[n]one in positions 11-13, one in 23-25, and [n]one in 31-33.

With findThis = '(one).*(one)'

I get the results:

MATCH.RM_SO(1) = 10
MATCH.RM_SS(1) = 0
MATCH.RM_EO(1) = 33
MATCH.RM_ES(1) = 0
MATCH.RM_SO(2) = 10
MATCH.RM_SS(2) = 0
MATCH.RM_EO(2) = 13
MATCH.RM_ES(2) = 0
MATCH.RM_SO(3) = 30
MATCH.RM_SS(3) = 0
MATCH.RM_EO(3) = 33
MATCH.RM_ES(3) = 0
MATCH.RM_SO(4) = -1
MATCH.RM_SS(4) = 0
MATCH.RM_EO(4) = -1
MATCH.RM_ES(4) = 0
MATCH.RM_SO(5) = -1
MATCH.RM_SS(5) = 0
MATCH.RM_EO(5) = -1
MATCH.RM_ES(5) = 0
With your explanation, the first element shows the entire match range (10-33
as offset, or 11-34 as position), which makes sense. The second element
shows the match for 10-13 (the first [n]one). The third element shows the
last match at 30-33 (the last [n]one). However the middle match, one at
positions 23-25, is not shown.

Is it an issue with the regex expression, such as "one" versus
"(one).*(one)", the regexec, or both? Perhaps I spent too much time with
.NET; the .NET syntax "Regex.matches(findWithin, findThis).count" would
yield 3, expected for my example.

Thanks,
Loyd




On Wed, Feb 3, 2010 at 1:18 PM, Scott Klement <rpg400-l@xxxxxxxxxxxxxxxx>wrote:

Hi Dennis,

I think you misunderstand how the 'match' array is used. (Because your
code is working the way *I* expect, as well as the way it's documented
to work.)

The first element of the array will contain the entire match of your
pattern. The second element contains the match of the first
subexpression, the third contains the match of the second subexpression,
etc.

It will never show you multiple matches. Only the whole match, plus
subexpressions. And in your example, you didn't use any subexpressions.

For a demonstration, though, try changing your 'findThis' variable as
follows:

D findThis S 64 Varying Inz('(one).*(one)')

The parenthesis in my RE denote the subexpressions.

Keep the remaining code the same, just change that line. And run the
program. Now you should get 3 elements in the array.

The first element would contain the starting/ending positions of the
string 'none but the one' because that's the "whole pattern" match. The
second element would contain the starting/ending positions of the 'one'
from the word "none". (i.e. rm_so=10, rm_eo=13) The third element
should contain the starting/ending positions of the word 'one' from the
end of the sentence... i.e. rm_so=22, rm_eo=25.

Hope that makes sense. For a more "official" answer, see the ILE C
Runtime Library manual from IBM, here:

http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/books/sc415607.pdf

IMHO, IBM doesn't do a great job of explaining it. You might try the
man pages of your favorite Unix distro for a clearer explanation :)

On 2/3/2010 10:11 AM, Dennis Lovelady wrote:
Folks, I'm getting unexpected result from Regular Expression matching on
System i at V5R3. You can see the code in question at
http://code.midrange.com/e15d4eb99d.html.



I expect the expression to match on both the word "one" and the second
position of the word "none" but the search seems to stop after the first
match. (I can see that it has initialized all elements of match,
however,
for whatever that's worth.) To see the issue, run in debug mode and set
a
breakpoint at the line that contains "Match(es)". At that point, rc
should
be zero (and it is); the first element of match should point to the
second
character of done. (all good so far). But the second element of match
should point to the word "one" and it doesn't.



Can you see what might be wrong with this? Thanks.



Dennis E. Lovelady
AIM: delovelady MSN: fastcounter@xxxxxxxxxxxx
<http://www.linkedin.com/in/dennislovelady>
www.linkedin.com/in/dennislovelady --
"Nothing makes you more tolerant of a neighbor's noisy party than being
there."
- Franklin P. Jones




--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-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.