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



On 7/25/2023 12:33 PM, Jason Olson wrote:
When I do this,

exec sql
select
 REGEXP_COUNT('192.168.140.230', :ip_regex)
 into :count  from SYSIBM.SYSDUMMY1;

It's working fine. However, if I use a variable to hold the IP address it fails. I've tried char fields and varchar fields and it always fails. This is on 7.3.

Without seeing code or regex, my guess is that there's a fixed length variable (trailing blanks) being assigned to a varchar. FWIW, this works for me on 7.4:

dcl-s ip varchar(64) inz('192.168.140.230');
dcl-s ip_regex varchar(128) inz;
dcl-s count int(10) inz;

ip_regex = '^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}+
(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$';

exec sql
select
REGEXP_COUNT('192.168.140.230', :ip_regex)
into :count from SYSIBM.SYSDUMMY1;

dump(a) 'literal';

exec sql
select
REGEXP_COUNT(:ip, :ip_regex)
into :count from SYSIBM.SYSDUMMY1;

dump(a) 'variable';

*inlr = *on;


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.