Re: Regular Expression Question

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



=?windows-1252?Q?Arne_Vajh=F8j?= <arne@xxxxxxxxxx> wrote:
Nicholas Paldino [.NET/C# MVP] wrote:
I don't know if it is faster, but it would be much easier to
maintain, from my point of view. Regular Expressions are definitely a
good thing, and worth using, but usually overkill for simple patterns.

One advantage of regex is that if the pattern used may need to be
extended later to more complex ones, then a regex is usually much easier
to extend than IndexOf and Substring.

Hmm, not in my experience. Each time you maintain it, you have to make
sure you fully understand the exact nature of the pattern, and then
carefully change it, ensuring that you escape everything that needs to
be escaped etc.

If you're doing real *pattern* stuff which isn't easily expressed with
Contains/IndexOf etc, then regexes are appropriate - but otherwise I
find the explicit operations easier to understand.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.



Relevant Pages

  • Re: [OT] Re: Chris Sonnack on VB.Nets putative Set statement
    ... > regex is in a C-ish language string. ... the ease of making errors in regular expressions is a concern ... You do need to replicate the pattern on either side of the comma ...
    (comp.programming)
  • Re: Regex doubt
    ... regular expressions to match HTML. ... > I'm a bit of a newbie to RegEx - and I'm trying to write a RegEx which ... > pattern, match the pattern itself?In that case, the first pattern could be ...
    (microsoft.public.dotnet.framework)
  • Re: Regex Replace Help
    ... You're specifically looking for a pattern that consists of an &, not followed by any alphanumeric characters and a;. ... And last but not the least i collect all answers posted to my Regex ... learning regular expressions will be worth it. ... I'll try to play with it later today but no promises. ...
    (microsoft.public.dotnet.framework)
  • Re: Need help with a regular expression to match words containing asterisk
    ... Apparently that was the regex I had not tried. ... > do not match regular expressions; ... A ksh example of a file name pattern that isn't a RE ...
    (comp.unix.shell)
  • [SUMMARY] Statistician I (#167)
    ... The heart of this problem, as suggested in the quiz description, is pattern ... have the pattern matching in place, the rest of the code is pretty trivial. ... use regular expressions, or at least review their knowledge. ... Next, as indicated in the comment, square brackets surrounding text are ...
    (comp.lang.ruby)