× Home About AS400 Files on AS400 Bit Operations Compile Commands EBCDIC Table Edit Codes Message Subfile Reg. Expressions Sort Contact us


RPG - LANGUAGE

Reg. Expressions


REGEXP is a function which operates on AS400 / ISERIES as a regular expression processor.
It is presented as a module which you link into your program at compile time (CRTPGM).
This is Version 1.0, and is available freely to use.
Download the readme file here.
Download the savfile here.


Literal Characters

\0 zero NULL
\t lowercase t Horizontal TAB
\n lowercase n New Line
\v lowercase v Vertical TAB
\f lowercase f Form Feed
\xnn lowercase x Hexadecimal character represented by nn
\d lowercase d matches any digit 0-9
\D uppercase D matches what is not a digit
\w lowercase w matches any alphanumeric, a-zA-Z0-9_
\W Uppercase W matches what is not alphanumeric
\c lowercase c matches any alphabetic, a-zA-Z
\C Uppercase C matches what is not alphabetic, a-zA-Z
\s lowercase s matches any whitespace character
\S uppercase S matches any non-whitespace character


Punctuation Characters

^ carat match the beginning of a string or line
$ dollar sign match the end of a string or line
. stop wildcard - matches any character
* asterisk zero or more matches
+ plus one or more matches
? question mark the match is optional, may or may not match
| vertical bar alternative (or)
\ back slash escape character, the following character has a specific meaning
() round brackets subexpression
{} braces number of occurrences to match
[] square brackets sequence or range of characters to match


Examples ...
text='alpha'
expression='qwe'
     will not find a match,
     and so return a -1.

text='alpha'
expression='h'
     will find a match starting in position 4,
     and so return a 4.

text='alpha'
expression='\w'
     will find a match starting in position 1,
     and so return a 1.

text='alpha'
expression='\W'
     will not find a match,
     and so return a -1.

text='alp25a'
expression='\d'
     will find a match starting in position 4,
     and so return a 4.

text='myname@emailaddress.zx'
expression='\w+@\w+\.\w{2,3}$'
     will find a match starting in position 1,
     and so return a 1.

text='myname@emailaddress.zxy'
expression='\w+@\w+\.\w{2,3}$'
     will find a match starting in position 1
     and so return a 1.

text='myname@emailaddress.zxywv'
expression='\w+@\w+\.\w{2,3}$'
     will not find a match,
     and so return a -1.

text='myname@emailaddress.zx'
expression='\w+@\w+\.\w{2,3}'
     will find a match starting in position 1,
     and so return a 1.

text='myname@emailaddress.zxy'
expression='\w+@\w+\.\w{2,3}'
     will find a match starting in position 1,
     and so return a 1.

text='myname@emailaddress.zxywv'
expression='\w+@\w+\.\w{2,3}'
     will find a match starting in position 1,
     and so return a 1.

text='alph123'
expression='^\w+\d'
     will find a match starting in position 1,
     and so return a 1.

text='alph123'
expression='^\w\d'
     will not find a match,
     and so return a -1.



You can email us here or use the Contact Us menu tab.




a mckaysoftware website