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

Re: Regx: match without regarding space and case

by GrandFather (Saint)
on Sep 13, 2007 at 07:14 UTC ( [id://638743]=note: print w/replies, xml ) Need Help??


in reply to Regx: match without regarding space and case

Use the translate operator (see tr/SEARCHLIST/REPLACEMENTLIST/cds) to delete the spaces, then use a case insensitive match. The code below captures the matched string to retain the original case, but doesn't attempt to figure out the "spacey" version of the match:

use strict; use warnings; my $x="My name is VC"; my $y="myname"; $x =~ tr/ //d; print "Matched: >$1<\n" if $x =~ /(\Q$y\E)/i;

Prints:

Matched: >Myname<

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Regx: match without regarding space and case
by Skeeve (Parson) on Sep 13, 2007 at 10:47 UTC

    but doesn't attempt to figure out the "spacey" version of the match:

    But getting the spacey version was what the OP was asking for, wasn't it?


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-24 17:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found