Re: C# Beginings

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"Jesse Houwing" <Jesse.houwing@xxxxxxxxxxxxxxxx> wrote in message
news:21effc90da398c9aa5678db3ca9@xxxxxxxxxxxxxxxxxxxxx
Hello Michael,

Hello Jesse


This is also partly due to the fact that:
- people don't know enough of regular expressions to use a truly good
tactic

Indeed!

to tackle the problem (usually leading to enormous expressions)

No Shit! =)

- people never embed comments in regular expressions (?#.....)

comments, comments, comments!

- poeple never use verbatim strings in C# to make their expression
readable

RegExps readable? What planet are you from, dilbert? *S*

- even the best C# programmers usually try to avoid regex (and
parser/scanners for that matter) like the plague, never truly mastering
the technique.

Too me more serious, you really have to master it.
- I would trust a Sensei in RegExps creating good ones.

Too bad that most coders suck at it. =)

- if you've had to maintain expressions from others, you probably hate
regex by now, while you should hate the others in fact

I hate the lame coders, that thinks they mastered it. Not RegExp per se.

So these are the rules for Regex use:
- Use them right

Thanks Master of The Obvious. =)

- make them as simple as possible

Yes

- split the problem into multiple expressions, use passes for easch step
in the validation (as you would do in C#)

Hmm. That would give a O(N) or even a O(N^2) problem.

If you need several expressions, RegExps are not the way to go. Use for,
foreach and while instead... .. ...

- combine the strength of regex with the raw power of C# when needed,
don't try to do everything with an expression. (also don't try to do
everything with string manipulation)(or is that part of use them right)

.... which we tend to agree with. =)

- comments, comments, comments (or is that part of make them as simple as
possible)

Jesse


The guru Knuth said:
- Whenever you feel the need to comment your code, check your code and see
how you can improve it to get rid of the comment.

Knuth has obviously never done any RegExps. =)

who has been teaching a regex class for the past 3 years and can still be
surprised by both the strange things people try to do with regex and the
powerful expressions I'd never before thought possible.


And I am calling it RegExps. Silly me.
Is the first lesson all about that it is called 'regex' and not 'RegExp'?

For real Jesse, thanks for a great post.

My Best Regards
- Michael Starberg





.



Relevant Pages

  • Re: C# Beginings
    ... RegEx is a 'write only language'. ... I hate RegExps, but that may be because I have seen it overdone into ... bombastic 100-dimension expressions. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regular Expressions for RETURN
    ... If you actually want to search for a RETURN character, ... backslash operator is used only for special regular expression ... NOT for entering control characters in the regexps. ... expressions to replace for example two lines by one? ...
    (comp.emacs.xemacs)
  • Re: Regular Expressions for RETURN
    ... If you actually want to search for a RETURN character, ... However, the end of line is marked by ctrl-J LINEFEED, not ctrl-M ... NOT for entering control characters in the regexps. ... expressions to replace for example two lines by one? ...
    (comp.emacs.xemacs)
  • Re: [9fans] du and find
    ... Regexps in Plan9 are on one hand much less powerful than Perl's, ... Often one doesn't need Perl's power and in such a case Plan9's regexps ... It's always been easier for me to use python's/perl's regular ... expressions when I needed to process a text file than to use plan9's. ...
    (comp.os.plan9)
  • Re: Slow regular expressions :(
    ... you are misunderstanding the extend of the problem if you think ... with very complex expressions or expressions that ... even if you are en expert with RegExps. ... You would be better of using a real parser or ...
    (comp.lang.ruby)