Connecting Tech Pros Worldwide Help | Site Map

cannot get this regex to work!

  #1  
Old April 8th, 2008, 10:55 AM
Geoff Cox
Guest
 
Posts: n/a
Hello,

I have just come back to regex to change a whole lot the x values in
for example to the number/s (this can be 1, 2 or 3 digits) following
the under score character, but cannot get it to work.

So for example,

<fred figure2_312.bmp" Get1(x)>

becomes

<fred figure2_3=312.bmp" Get1(3)>

I have tried

$line =~ /.*_?(\d)\..*?>/;
$line =~ s/x/$1/;

A little help please!

Cheers

Geoff

  #2  
Old April 8th, 2008, 04:35 PM
Jürgen Exner
Guest
 
Posts: n/a

re: cannot get this regex to work!


Geoff Cox <gcox@freeuk.notcomwrote:
Quote:
>Hello,
>
>I have just come back to regex to change a whole lot the x values in
>for example to the number/s (this can be 1, 2 or 3 digits) following
>the under score character, but cannot get it to work.
>
>So for example,
>
><fred figure2_312.bmp" Get1(x)>
>
>becomes
>
><fred figure2_3=312.bmp" Get1(3)>
use warnings; use strict;
$_ = '<fred figure2_312.bmp" Get1(x)>';
s/_(\d)/_=$1/;
my $x = $1;
s/x/$x/;
print;

BTW: this NG has been officially deleted over a decade ago and replaced
with the whole comp.lang.perl.* hierarchie.

jue
  #3  
Old June 27th, 2008, 05:33 PM
Jürgen Exner
Guest
 
Posts: n/a

re: cannot get this regex to work!


Geoff Cox <gcox@freeuk.notcomwrote:
Quote:
>Hello,
>
>I have just come back to regex to change a whole lot the x values in
>for example to the number/s (this can be 1, 2 or 3 digits) following
>the under score character, but cannot get it to work.
>
>So for example,
>
><fred figure2_312.bmp" Get1(x)>
>
>becomes
>
><fred figure2_3=312.bmp" Get1(3)>
use warnings; use strict;
$_ = '<fred figure2_312.bmp" Get1(x)>';
s/_(\d)/_=$1/;
my $x = $1;
s/x/$x/;
print;

BTW: this NG has been officially deleted over a decade ago and replaced
with the whole comp.lang.perl.* hierarchie.

jue
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to overwrite the FORM ACTION attribute wwwmike@gmx.ch answers 4 January 3rd, 2007 09:25 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 09:56 PM
comp.lang.c Answers to Frequently Asked Questions (FAQ List) Steve Summit answers 0 November 13th, 2005 03:15 AM
Regular Expressions, WSH, and not getting New RegExp to work at all Bã§TãRÐ answers 3 July 19th, 2005 11:46 AM