http://www.perlmonks.org?node_id=1050642


in reply to Re^2: Perl Regex Match (Compare Only AlphaNumeric)
in thread Perl Regex Match (Compare Only AlphaNumeric)

Work on a copy of the data for the testing...

UPDATE: I think I now understand what you want. Try something like this:

my $regex = join '\s+', qw( New Store Opening Promenade in Crocker Par +k Rack Nordstrom Rack is a division of Nordstrom ); $out = $1 if ($data_main =~ /($regex.*)/is);

Replies are listed 'Best First'.
Re^4: Perl Regex Match (Compare Only AlphaNumeric)
by Anonymous Monk on Aug 23, 2013 at 12:04 UTC
    Thanks hdb, I checked, this will work for me in 90% cases... Thanks for your time... :)

      You can make it more general. If you replace '\s+' by something like '[^a-zA-Z0-9]+' then it will match more often.

Re^4: Perl Regex Match (Compare Only AlphaNumeric)
by Anonymous Monk on Aug 23, 2013 at 12:26 UTC
    Hi Hdb, I tried something like this, but not working. Is there any way to define that string seperately as I done here.
    $qqq = "New Store Opening Promenade in Crocker Park Rack Nordstrom Rac +k is a division of Nordstrom"; my $regex = join '\s+', qw($qqq); $out = $1 if ($data_main =~ /($regex.*)/is);

    Its the same code except that string is defined separately. Will this not work? or is there another way to define that string seperately... Actually I want a global solution for this. I have may files similar which need to be done. thats why I need a global solution & not a hardcoded solution. Thanks

        Thanks Choroba, Is there any alternate for that to get it done?
      my $regex = join '\s+', split /\s+/, $qqq;
      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name"