I'm attempting to restrict the valid values that the user inputs to letters, numbers, spaces, opostrophes, periods and dashes.
I'm trying this subsitution to get rid of any offenders:
s/[^A-Za-z\d\s\-\.\']//g;
with a test value of
D3E' C@$o*r(-A[].Mick7that should return
D3E' Cor-A.Mick7but instead is returning
D3E' Cr-A.Mick7
What am I not understanding is what allows it to remove 'o' when I don't want it to? I figure it has something to do with the order in which things are matched and something about the 'o' being surrounded by offending characters, but I'm at a bit of a loss.
Thanks!
UPDATE: *d'oh* I had commented out the use warnings, use strict earlier because of some other issue and forgot to put them back in when I did more work.
Glad to know it was just some simple oversight rather than a complete lack of understanding on my part. Thanks!
I learn more and more about less and less until eventually I know everything about nothing.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.