Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: [Try-out] Regexp do's and don'ts

by nobull (Friar)
on Mar 27, 2005 at 22:13 UTC ( [id://442715]=note: print w/replies, xml ) Need Help??


in reply to Regexp do's and don'ts

Good document. I can hardly fault it technically.

A few suggestions (I am a native speaker of (British) English):

"look how cute, he's telling the obvious."

"look how cute, he's stating the obvious."

to search global

to search globally

The plural of 'regex' is sometimes written as 'regexen'. This is not a standard way of making a plural in English but it still seen quite often.

The wisdom of using strictures and taint mode has little to do with regexes. The whole section "Rules of Thumb" should be introduced as general Perl programming advice not RE specific advice. Perhaps even split this section off to a separate node.

tainted date

tainted data

they are/behave malicious

Can't make this work comfortably in English. They are malicious or they behave maliciously.

Don't trust users.

...or programs under their control.

getting president

standing for president

Check if you enter the right airplane before entering it.

Check if you are entering the right airplane before you enter it.

if both are not present.

Sorry the precedence of 'not' here is ambiguous in written English. (In spoken English it would be possible to disambiguate with intonation).

  • if neither are present.
  • unless both are present.
  • if both are absent.
($untainted) = $tainted =~ m/(.*)/g;

($untainted) = $tainted =~ m/(.*)/;
(And you just finished warning people not to use redundant qualifiers) :-)

This way, you only show you don't know why one would use taint mode and you make taint mode useles for your script.

This could be considered insulting. There's nothing wrong with unconditionally untainting data that is known for certain to come from a trusted source.

Replies are listed 'Best First'.
Re^2: [Try-out] Regexp do's and don'ts
by muba (Priest) on Mar 28, 2005 at 11:21 UTC
    Good document. I can hardly fault it technically.

    A few suggestions (I am a native speaker of (British) English):
    Alright, thank you! I edited the Original Post in order to use most of your suggestions.

    ($untainted) = $tainted =~ m/(.*)/g;
    ($untainted) = $tainted =~ m/(.*)/g;
    (And you just finished warning people not to use redundant qualifiers) :-)
    Oh, I had a really hard time finding out what the difference between the two lines of code is. But indeed. I altered it, so now it is ($untainted) = $tainted =~ m/(.*)/; :)

    Well, thanks!




    "2b"||!"2b";$$_="the question"
    Besides that, my code is untested unless stated otherwise.
    One more: please review the article about regular expressions (do's and don'ts) I'm working on.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-19 12:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found