Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re: Perl Regex Match (Compare Only AlphaNumeric)

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

in reply to Perl Regex Match (Compare Only AlphaNumeric)

Remove all the uninteresting characters from your data before testing for match, e.g. s/[^a-zA-Z0-9]//g.

Replies are listed 'Best First'.
Re^2: Perl Regex Match (Compare Only AlphaNumeric)
by Anonymous Monk on Aug 23, 2013 at 11:18 UTC
    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.

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

      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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050638]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2018-02-19 22:48 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (266 votes). Check out past polls.