On Mon, Feb 13, 2012 at 10:10 PM, Dr.Ruud <rvtol+use...@isolution.nl> wrote:
> On 2012-02-13 14:48, lina wrote:
>
>> $mystring3="abacadeusagaka35";
>>
>> if($mystring =~ m/(a.+)/g){
>>        print $1,"\n";
>> }
>>
>> Hi, I wonder how to print the "abacad" out?
>
>
> I assume you are looking for /((?:a.)+)/.
>
>
> perl -Mstrict -wle '
>  my $s = shift;
>  print $1 while $s =~ /((?:a.)+)/g;
> ' abacadeusagaka35
> abacad
> agaka3
>
>
> perl -Mstrict -wle '
>  my $s = shift;
>  print for $s =~ /(?:a.)+/g;
> ' abacadeusagaka35
> abacad
> agaka3

The way of testing on terminal is nice, but how to apply to multi-lines,

$ perl -Mstrict -wle '
$s = shift ;
print $1 while $s =~ m/^(.*) /;
' "abe efg \ntu as"
Global symbol "$s" requires explicit package name at -e line 2.
Global symbol "$s" requires explicit package name at -e line 3.
Execution of -e aborted due to compilation errors.




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

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