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

hdb, but how can I make it back as it was...? if I remove the uninteresting characters, the there will be No space or new line in the desired output.
  • Comment on Re^2: Perl Regex Match (Compare Only AlphaNumeric)

Replies are listed 'Best First'.
Re^3: Perl Regex Match (Compare Only AlphaNumeric)
by hdb (Monsignor) on Aug 23, 2013 at 11:20 UTC

    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);
      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.

      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

        my $regex = join '\s+', split /\s+/, $qqq;
        use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name"
Re^3: Perl Regex Match (Compare Only AlphaNumeric)
by AnomalousMonk (Archbishop) on Aug 23, 2013 at 11:22 UTC

    If you're not interested in them, why put them back? As choroba suggested, a clearer statement of the problem may lead to better understanding for all, including yourself.