How to use comments in Regular Expression patterns
If you’ve ever needed to analyze a complicated Regular Expression pattern that someone else has written, you know it can sometimes be very painful to decipher what his or her thought process was with the pattern. Unlike Data Types, Data Formats do not have a Description property to document their uses.
There is, however, a solution to this problem. Similar to programming languages, you can use comments in your Regular Expression patterns.
What is a comment?
For those unfamiliar, a comment is a piece of syntax in your code that acts as a “note,” either for your documentation, or for someone else who may inherit this particular item later on down the road. This syntax isn’t actually included in the code when it gets processed, so it’s purely for documentation.
Future you and/or your successor will thank you if you document your methodology, and this provides an easy way to do so.
Syntax
The syntax for writing a comment in a Regular Expression pattern is as follows:
Example
The comments in the middle of the pattern have no effect on the rest of the pattern.
Responses