On Oct 16, 2012, at 8:10 AM, xiyoulaoyuanjia wrote:

> hi listers:
> i am very sorry to say that i recently get in trouble with a Regular !
> i want math the middle of 123 and 456 string!
> the Test Case below:
> ------------------------------------------
> 123faf456fafafafa----->faf
> 
> 33312323ff456456--->23ff
> 
> 9999912344444456777777456-->44444
> -------------------------------------------------
> i have try a regular but it get trouble!
> can anyone help me?

The best way to get help with a Perl problem is to post a minimal program that 
demonstrates the problem you are having.

Here is a program that might help:

#!/usr/bin/perl
use strict;
use warnings;

my @x = ( '123faf456fafafafa', '33312323ff456456', 
'9999912344444456777777456' );

for my $s ( @x ) {
        if( $s =~ m{ 123 (.*?) 456 }x ) {
                print "$s -> $1\n";
        }else{
                print "No match\n";
        }
}


which produces:

123faf456fafafafa -> faf
33312323ff456456 -> 23ff
9999912344444456777777456 -> 44444



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to