[Cialug] text munging

Josh More morej at alliancetechnologies.net
Thu Oct 26 07:54:21 CDT 2006


In Perl:

\d{1,9}$ 

should match any string of digits of length ranging from 1 to 9, located
at the end of a line.
So, it's just matter of nesting the regex in parens and using $1 as the
string with the digits.
The length of $1 will give you the count of digits, if you need it.



-- 
-Josh More, RHCE, CISSP, NCLP 
 morej at alliancetechnologies.net 
 515-245-7701
>>> Dave Weis <djweis at internetsolver.com> 10/26/06 7:13 AM >>>

I have a small file processing problem. I have a file consisting of rows

like this:
DESMIAAW	RT 6650 ASHWORTH
RD	WDMNIAAQ		410701	410702	410704	410801

410803	411101

DESMIAAW	DSLAM 7410 ASPEN DR	WDMNIAIA	ADSL	410801					
The first row has a variable number of 6 digit numbers at the end, the 
row after doesn't have that. I need to end up with the row "normalized" 
so if it gets in a row with 6 numbers at the end, I want six rows out 
with each number in the sequence at the end. There can be up to 9 of the

numbers at the end.

I can do something similar in perl or awk but never bothered to learn 
how to do the variable number of repeating numbers bit.
_______________________________________________
Cialug mailing list
Cialug at cialug.org
http://cialug.org/mailman/listinfo/cialug



More information about the Cialug mailing list