Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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

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 snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2018-01-22 09:24 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.