[clue-tech] Simple Perl regex

Bruce Ediger bediger at stratigery.com
Thu Dec 16 20:48:01 MST 2010


On Thu, 16 Dec 2010, Jed S. Baer wrote:

> blah xmlUrl="stuph I want to extract" more blah
>
> grab the string inside the quote marks, introduced by 'xmlUrl='.
>
> So I have this:
>  if ( $foo =~ /xmlUrl=\"(.+?)\"/ ) {
>     # if we get here, then $1 is stuph I want to extract
>     print "$1\n";
>  }

It works fine for me:

  8:46PM 15 % cat ./rgx1.pl
#!/usr/bin/perl
use strict;
use diagnostics;

my $foo = 'blah xmlUrl="stuph I want to extract" more blah';

         if ( $foo =~ /xmlUrl=\"(.+?)\"/ ) {
                 print "$1\n";
         }

  8:46PM 16 % ./rgx1.pl
stuph I want to extract
  8:46PM 17 %

Maybe your input doesn't contain what you think it does?


More information about the clue-tech mailing list