Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Perl Regex Match (Compare Only AlphaNumeric)

by hdb (Prior)
on Aug 23, 2013 at 11:20 UTC ( #1050642=note: print w/ replies, xml ) Need Help??


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


Comment on Re^3: Perl Regex Match (Compare Only AlphaNumeric)
Download Code
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"

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050642]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (13)
As of 2014-10-21 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (103 votes), past polls