[H-GEN] REGEX pattern required

Gary Curtis gazilla at gmail.com
Tue Dec 7 21:43:33 EST 2004


Whenever I bring up the subject of parsing text all the regex 
fiends jump up and down, singing its vitues. So here is your
chance to show me how good it is...

Whart I want is a pattern to extract the RIGHT-MOST set
of numeric digits in the following test strings. I plan to use
the PHP function reg_split (or preg_splt), and hope to get
a three element array.   array[1] will contain all text to the left
of the digits (perhaps null),  array[2] will contain the digits, and
array[3] will contain all text to the right of the digits (or null).

You may assume there is always at least one digit somewhere
in the string and NO spaces.

Examples:
123                      null  123  null
123abc                null  123  abc
jk234                    jk  234  null
abc34fgh             abc   34   fgh
a9bc456              a9bc   456   null
K+v5678aa=x       K+v    5678   aa=x
aa00001-123b     aa00001-   123   b

Can this be accomplished with just one pattern?

Gaz
-- 
---------------------------------------------------------------------------------------------------
And remember, it's spelled Gary Curtis, but it's pronounced "Gazilla"




More information about the General mailing list