Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Benchmarking "Are all these characters in this sentence?"

by martin (Friar)
on Sep 05, 2008 at 14:33 UTC ( #709290=note: print w/replies, xml ) Need Help??


in reply to Benchmarking "Are all these characters in this sentence?"

Just for completeness, try this one, too:
martin => sub { # args: sentence, wantedchars '' eq $_[1] || '' ne $_[0] && $_[1] =~ /^[\Q$_[0]\E]*\z/; },
Putting the whole sentence into a character class will kind of suck with veeery long sentences but medium-sized cases should benefit from the one-pass approach.

Update: fixed the order of subroutine parameters

Replies are listed 'Best First'.
Re^2: Benchmarking "Are all these characters in this sentence?"
by RMGir (Prior) on Sep 05, 2008 at 17:22 UTC
    You're checking whether only the wantedchars are used.

    That wouldn't work. The question isn't whether the sentence consists ONLY of characters in the wantedchars, just whether or not ALL the wantedchars are present.


    Mike
      You're checking whether only the wantedchars are used.

      Not quite. It's supposed to be the other way round. The idea is to check whether $wantedchars only contains characters from $sentence.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://709290]
help
Chatterbox?
[1nickt]: stevieb it turns out that Dell still has the Precision line of "mobile workstations", just not displayed on their main website. I found the Precision 7710 with 4k display/full-size keybd as req'd.
[1nickt]: List $2,788 (!), on sale for $1766, also a $200 coupon on the site thru 3/30 ... final price $1,566. Includes 3-yr on-site service.

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2017-03-27 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (320 votes). Check out past polls.