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



Well I solved my own problem by making the matches array a multi-occurring
data structure instead of a dimmed array.

However I am getting a message about my regular expression returned back
from regcomp(). Can anyone see what's wrong with the regular expression
below? I'm not exactly sure what the difference is between the regex
processor on the 400 and the tester I'm using at
http://gskinner.com/RegExr/, but it works in the tester just fine. Here is
the pattern and the message its giving me.

Its looking for the '#123A' in a string like 'Store #123A'

pattern = '(?:\s+)(?:#)\s{0,5}([0-9a-z]+)';
rc = regcomp(reg :pattern :REG_EXTENDED + REG_ICASE);

The run time error (code 13 returned from regcomp):
?, * or + not preceded by valid regular expression

Thanks,
Robert Newton
EDPS
Electronic Data Processing Services
System Owner
804-353-1900 x2256
rnewton@xxxxxxxxxxxx


|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|RNewton@xxxxxxxxxxxx |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|RPG programming on the IBM i / System i <rpg400-l@xxxxxxxxxxxx> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|06/11/2009 11:35 PM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Processing the Regexec() Matches Array |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|rpg400-l-bounces@xxxxxxxxxxxx |
>--------------------------------------------------------------------------------------------------------------------------------------------------|






I'm having trouble getting Regexec() to compile in my program. I'm using
the example regex_h that Scott put out a couple years ago. I've searched
archives but can't find any instances where people are trying to use the
returned matches array. Most are just using it as a validation process for
emails.

My intention with the code below is to run the regexec and loop through the
matches in order to do something with those words that matched the pattern.
However, the compiler is giving me a message about the 4th parameter not
being able to be passed by reference. I am stuck on this one and can't seem
to figure out what silly mistake I'm making. Can anyone help me out?

The compiler error...

*RNF7542 30 001060 Parameter 4 is not valid as a parameter passed
by

reference.

*RNF7542 30 1 Parameter cannot be passed by reference when it can be

changed during the call.

Here is what I have...

d buffer s 1000a inz
d pattern s 512a inz('(?:\s+)(?:#)\s{0,5}([0-9a-z]+)')
d reg ds likeds(regex_t)
d numMatches s 10u 0 inz(100)
d matches ds likeds(regmatch_t) dim(100)
d rc s 10i 0
d len s 5u 0 inz
d foundWord s 100a inz

//Compile the regular expression
rc = regcomp(reg :pattern :REG_EXTENDED + REG_ICASE + REG_NOSUB);
if rc <> 0;
return;
endif;

//Execute the regular expression to find pattern matches
rc = regexec(reg :%trim(buffer) :numMatches :matches :0);
if rc = 0;

//Loop through each of the matched words
for i = 1 by 1 to numMatches;

//Get the length of the found word
len = matches(i).rm_eo - (matches(i).rm_so + 1);

//Extract the word found to match the pattern
foundWord = %subst(buffer :matches(i).rm_so+1 :len);

endfor;

endif;


Thanks,
Robert Newton
EDPS
Electronic Data Processing Services
System Owner
804-353-1900 x2256
rnewton@xxxxxxxxxxxx



This communication and any transmitted documents are intended to be
confidential. If there is a problem with this transmission, please contact
the sender. If the reader of this message is not the intended recipient, or
the employee or agent responsible to deliver it to the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited.

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






This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.


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.