By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,841 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,841 IT Pros & Developers. It's quick & easy.

cannot get this regex to work!

P: 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

Apr 8 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Geoff Cox <gc**@freeuk.notcomwrote:
>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
Apr 8 '08 #2

P: n/a
Geoff Cox <gc**@freeuk.notcomwrote:
>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
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.