Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Action Items

So here's the plan I recommend for your RE career. If you haven't done so already, read up on the RE library available in your specific C or C++ development environment. Find a mentor—RE seems to be a concept whose comprehension a quick "live" conversation especially helps. Start using REs for increasingly difficult parsing chores: flagging passwords that consist of characters all in the same case, looking for the context of all words repeated at least twice, checking for abbreviations of keywords, and so on. Learn a parser library for XML or (if you work in one of the few areas of programming not yet XMLified) for C itself.

Finally, keep in mind that you should comment your REs at least as well as the main body of your C or C++ source. It's true that REs have traditionally been coded as inscrutable "line-noise," jumbles of special characters such as Dr. Csaba Nemethi's {^[+-]?[0-9]*\.?[0-9]*([0-9]\.?[eE][+-]?[0-9]*)?$}.

Most modern RE libraries permit comments (as well as alternate delimiters that facilitate expression of those comments), so this particular instance can be written far more readably. When recoded as follows, it becomes far more apparent that this is an RE to match a number in scientific notation:

{^ # Match the entire string, from start to finish.

[+-]? # One sign is permitted, but not required.

[0-9]* # There can be digits before the decimal point.

\.? # Although the point itself isn't required.

[0-9]* # Digits after the decimal are also optional.

([0-9]\.?# An exponent is permitted but not required.

[eE] # It might appear in upper or lower case.

[+-]? # The exponent's value might be signed.

[0-9]* # The exponent can be any integer.

)? # Zero or one exponents.

$ # ... to finish.

}

With this background, you, too, will be a safe and productive RE user.

  • + Share This
  • 🔖 Save To Your Account