Click here to get back home

Re: counting the number of characters that were matched in a regular expression

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Re: counting the number of characters that were matched in a regular expression Glenn Jackman 04-16-2008
Posted by Glenn Jackman on April 16, 2008, 3:42 pm
Please log in for more thread options
At 2008-04-16 03:08PM, "PugetSoundSylvia@gmail.com" wrote:
> In a string, I need to replace all instances of 15 or 16 number
> characters with the 11 or 12 "x" characters, then the last 4 digits of
> the 15 or 16 number characters. The chunk of number characters may
> appear numerous times in the string.

You want s/(\d)(\d)/"x" x length($1) . $2/eg

Note the 'e' modifier


--
Glenn Jackman
"If there is anything the nonconformist hates worse than a conformist,
it's another nonconformist who doesn't conform to the prevailing
standard of nonconformity." -- Bill Vaughan

Similar ThreadsPosted
Re: counting the number of characters that were matched in a regular expression April 16, 2008, 3:20 pm
regular expression problem ? and * characters May 28, 2006, 7:01 am
Re: regular expression problem ? and * characters May 29, 2006, 6:41 am
Regular expression don't match sequence of characters September 27, 2004, 7:09 am
Regular Expression for HTML Tags and Special Characters October 19, 2004, 12:51 am
phone number regular expression problem May 31, 2006, 9:24 am
phone number regular expression problem May 31, 2006, 9:25 am
Regular expression to match month number 1,...,12 (including e.g. 04,05) September 14, 2004, 10:52 pm
Adding a delimiter inbetween number characters and letter characters January 12, 2005, 9:25 am
Counting lines in big number of files - in parallel. June 3, 2008, 5:14 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap