Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Phone number to word conversion

by aquarium (Curate)
on Nov 12, 2010 at 03:47 UTC ( [id://870979]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Phone number to word conversion
in thread Phone number to word conversion

if you also want substring matching..merely remove the start and end anchors in the regex. if you instead want all permutations of the number (digits in any order) mapping onto words, it's a little more complicated.
the hardest line to type correctly is: stty erase ^H

Replies are listed 'Best First'.
Re^4: Phone number to word conversion
by aquarium (Curate) on Nov 12, 2010 at 03:57 UTC
    in the end you will find that you have to come up with a very fine specification for what is and isn't acceptable during your mapping, as those choices will substantially influence technique. for example you could also want any number of letters in any permutation, as long as there's at least one or more of a particular digit. The digit 1 could be used as a wildcard, etc, etc. The most straightforward case--what does my full phone number spell as an entire word in that sequence--is a very easy regex.
    the hardest line to type correctly is: stty erase ^H

      > you have to come up with a very fine specification for what is and isn't acceptable during your mapping

      I don't mean to sound insulting, but I did come up with one. Please take a careful look at the original post.


      --
      "Language shapes the way we think, and determines what we can think about."
      -- B. L. Whorf
        what about if you turn the /etc/words into number combinations instead, and grep each such number combination into your chosen number, stripped of 0's and 1's?
        the hardest line to type correctly is: stty erase ^H
Re^4: Phone number to word conversion
by oko1 (Deacon) on Nov 13, 2010 at 02:33 UTC

    > if you also want substring matching..merely remove the start and end anchors in the regex.

    I'm sorry, you seem to have conflated the string and the regex. That won't work; it's equivalent to saying that /foobar/ will match "ooba" because there aren't any anchors in it. The problem is quite a bit more complicated than that; please take a look at both the specification in my original post and JavaFan's solution, which addresses it perfectly.


    --
    "Language shapes the way we think, and determines what we can think about."
    -- B. L. Whorf

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (1)
As of 2024-03-19 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found