Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Perl Regex Match (Compare Only AlphaNumeric)

by hdb (Prior)
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.




Comment on Re: Perl Regex Match (Compare Only AlphaNumeric)
Select or Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2015-07-02 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (41 votes), past polls