Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old April 8th, 2008, 10:55 AM
Geoff Cox
Guest
 
Posts: n/a
Default cannot get this regex to work!

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
Default 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
Default 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
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles