|
date: Thu, 22 Dec 2016 16:30:53 +0000
from: "Hiebert, Chris" <chris.hiebert@xxxxxxxxxxxxxx>
subject: RE: SQL function equivalent to TestN?
We are on V7R1 and can use regular expressions to replicate that behavior.
Here is a very simple example:
WITH T1 (VFLD) AS (VALUES ('not a number'),('156,156'),('1 '),(' 1 ') )
/* in order to run INT your string can't have any commas */
select INT(replace( VFLD , ',' , '' ))
Where length(trim(vfld)) > 0 And
/* skip strings that have anything that is not a digit or a comma */
REGEXP_COUNT( trim(vfld) , '[^(\d|,)]' ) = 0 and
/* Include strings that have a digit or a comma. */
REGEXP_COUNT( trim(vfld) , '[(\d|,)]' ) > 0
;
Chris Hiebert
Senior Programmer/Analyst
Disclaimer: Any views or opinions presented are solely those of the author
and do not necessarily represent those of the company.
This mailing list archive is Copyright 1997-2026 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.