Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: regular xpression stuff

by Masem (Monsignor)
on Jan 20, 2002 at 21:00 UTC ( #140218=note: print w/ replies, xml ) Need Help??

in reply to regular xpression stuff

In this case, you don't want a regex, at least directly. I think we've golfed this once, but in general:
my $to_be_matched = 'tab'; my $word = 'bat'; if ( join '', sort split(//, $word) eq join '', sort split(//, $to_be_matched ) ) { # Success! } else { # Failure }

Update - $ instead of @ on to_be_matched

Dr. Michael K. Neylon - || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important

Comment on Re: regular xpression stuff
Download Code
Replies are listed 'Best First'.
Re: Re: regular xpression stuff
by screamingeagle (Curate) on Jan 21, 2002 at 04:30 UTC
    if ( join '', sort split(//, $word) eq join '', sort split(//, $to_be_matched ) ) {
    if ( join('', sort split(//, $word)) eq join('', sort split(//, $to_be +_matched)) ) {
    (extra parenthesis added )

    After adding the parenthesis , i get "Success" (i.e. "bat" = "tab" based on your example), without them the result is "Failure"

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (12)
As of 2016-05-26 22:02 GMT
Find Nodes?
    Voting Booth?