Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: reversing a compiled regex?

by OM_Zen (Scribe)
on Mar 26, 2003 at 19:27 UTC ( #246051=note: print w/ replies, xml ) Need Help??


in reply to reversing a compiled regex?

Hi ,

The not in can be implemented by this I guess

my $a = "SCALAR"; my $str = "TT"; my $regexs = qr/[^\Q$str\E]/i; $a =~ s/$regexs/HOO /g; print "[$a]\n"; __END__ [HOOHOOHOOHOOHOOHOO]



Comment on Re: reversing a compiled regex?
Download Code
Replies are listed 'Best First'.
Re: Re: reversing a compiled regex?
by MarkM (Curate) on Mar 27, 2003 at 02:30 UTC

    This is not a correct conclusion or suggestion. Take a look at your code again:

    my $regexs = qr/[^\Q$str\E]/i;

    [] is used to define a character class, not a regular expression grouping. The statement above reads: "at least one character not found in $str." The reason your test code did not show you this is because you were matching:

    ($a = "SCALAR") =~ s/[^TT]/HOO/gi;

    Or, simplified:

    ($a = "SCALAR") =~ s/[^T]/HOO/gi;

    Since every character in the string "SCALAR" is "not T", every character is replaced with HOO. The original request was for a method of implementing !// using only //.

    Please put a little more thought into your response... Cheers...

      Hi MarkM ,

      Thanks for the reply , I got the actual post only now. That was totally my mistake . I see the solution from the other fellow reply . I shall surely give a little thought into my response .

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-29 01:31 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 (260 votes), past polls