Regex Guru

Tuesday, 15 April 2008

Watch Out for Zero-Length Matches

Filed under: Regex Trouble — Jan Goyvaerts @ 14:51

Zero-length matches are often an unintended result of mistakenly making everything optional in a regular expression. Sometimes they can be useful. In browsers like Firefox, zero-length matches can cause your JavaScript code to loop forever on regex.exec().

Tuesday, 8 April 2008

Unintended Backtracking Can Bite You

Filed under: Regex Trouble — Jan Goyvaerts @ 17:01

Backtracking occurs when the regular expression engine encounters a regex token that does not match the next character in the string. The regex engine will then back up part of what it matched so far, to try different alternatives and/or repetitions. Understanding this process will make all the difference between guessing and understanding why a […]

Friday, 4 April 2008

Escape Characters Only When Necessary

Filed under: Regex Philosophy — Jan Goyvaerts @ 12:35

The general rule is to only escape a character only if it really has to be escaped.

Thursday, 3 April 2008

wxRegEx class in wxWidgets

Filed under: Regex Code — Jan Goyvaerts @ 16:24

The wxRegEx class in the wxWidgets library encapsulates the Advanced Regular Expressions engine developed by Tcl. I’ve added a page of detailed documentation for this class to www.regexp.info. RegexBuddy now includes a template for generating C++ source code snippets using wxRegEx.

Wednesday, 26 March 2008

No One-on-One Advice

Filed under: About Regex Guru — Jan Goyvaerts @ 9:32

I’m sorry, but this blog really isn’t a place for personal advice on regular expressions. Suggestions for topics that I should write about are very welcome.

Friday, 21 March 2008

preg_replace_callback

Filed under: Regex Code — Jan Goyvaerts @ 10:48

PHP’s preg_replace_callback() function allows you to do a search-and-replace using a dynamically generated replacement text which can be different for each regex match.

Tuesday, 18 March 2008

If You Do It Differently, Document It Clearly

Filed under: The Guru's Kitchen — Jan Goyvaerts @ 18:19

People get used to established standards. Even bad ones. If you come up with something better, make sure to explain it clearly, or brace yourself for lots of complaints you’re not following the old ways.

Saturday, 15 March 2008

Convenience and Compatibility

Filed under: Regex Philosophy — Jan Goyvaerts @ 15:39

Being overly strict about what input your program or web site accepts makes it hard to use. Being overly lax causes compatibility headaches with future versions.

Friday, 14 March 2008

Regex Trouble

Filed under: Regex Trouble — Jan Goyvaerts @ 8:49

Recap of 4 articles on regular expressions pitfalls I previously posted to www.regular-expressions.info

Thursday, 13 March 2008

Validating Credit Card Numbers

Filed under: Regex Examples — Jan Goyvaerts @ 8:33

Example regular expressions to check if a series of digits looks like a valid credit card number for any of the major brands.

Tuesday, 11 March 2008

No Spaces or Dashes

Filed under: Regex Philosophy — Jan Goyvaerts @ 10:01

It’s easier to use a trivial regex to strip out spaces and dashes from credit card numbers than to blame the customer for typing them in.

Tuesday, 4 March 2008

Welcome to Regex Guru

Filed under: About Regex Guru — Jan Goyvaerts @ 16:59

Introducing the Regex Guru blog.

« Previous Page