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

Re^5: Problem with regex wildcard operator (.)...?

by AnomalousMonk (Bishop)
on Sep 06, 2021 at 07:19 UTC ( #11136496=note: print w/replies, xml ) Need Help??

in reply to Re^4: Problem with regex wildcard operator (.)...?
in thread Problem with regex wildcard operator (.)...?

I am not sure why your code seems to work.

It works because \[ is just an escaped [, so tr/\[A-Z]/[a-z]/ is translating [ to [, ] to ], and uppercase to lowercase. Any other character, e.g., \, is unaffected.

Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^6: Problem with regex wildcard operator (.)...?
by Marshall (Canon) on Sep 06, 2021 at 07:35 UTC
    Thanks for the explanation! I did not think that an escape '\' would work within TR. Even though that does indeed work, I prefer my tr/A-Z/a-z/ because it is easy for me to understand it at a glance. Of course, mileage varies.
      I prefer ... tr/A-Z/a-z/ ...

      So do I - or better yet lc in this case. :)

      Give a man a fish:  <%-{-{-{-<

        Yes, lc() is rocket fast because this only involves fiddling with one bit within a byte. C and ASM can do this very, very quickly. This is just a minor point in the OP's code. This is in a "run once" initialization loop. No optimization here will make any difference at all in terms of user perceived performance.

        The OP does have a correct idea in that running a regex against all lines of the input dictionary will be so fast, that the complexity of that regex probably makes no difference at all. The idea of throwing away extraneous results that are either too long or too short in terms of number of characters also probably makes no difference.

        I think the problem here is that we do not have clearly defined textual description (meaning something that a human can understand) of what the code is supposed to do! Nobody here can "fix" code that doesn't do what it is supposed to do, if we don't know what it is supposed to do in the first place!

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2022-01-19 14:38 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (55 votes). Check out past polls.