Character Class Search Explainer Tool
2020-06-12 - By Robert Elder
No Visuals on AMP Pages
You're currently reading the AMP version of this page which loads fast, but doesn't have animations enabled. Visit the non-AMP version of this page for the interactive visuals.
This article is part of Series On Regular Expressions.
About This Visualization Tool
The purpose of this visualization tool is to clearly illustrate how regular expression character classes work. By demonstrating that character classes can be thought of as a simple list of acceptable characters to match, this visualization tool shows a concrete description of what a character class actually represents. The C source code above shows an equivalent representation of the specified search string that may contain almost any character class that you'd find in a typical regular expression. Currently, this tool supports many common character classes such as typical ranges like '[a-z]', or '[0-9]'. Other character class features such as class negation, hexadecimal ranges, escaped classes and several common escaped ASCII character are also supported. The input forms above can be changed to dynamically update the equivalent C code.
Caveats
This tool works by using a custom-written regular expression engine that is fairly complete, but still lacks support for a few significant features such as Unicode. Check out Regular Expression Test Cases and An LL Grammar For Regular Expression Parsing for more information.
Another consideration is that real regular expression engines don't loop through a long list of characters as the C source code above might imply. The C code is intended to be functionally correct rather than as efficient as possible. This tool could have been written to produce C code that was as efficient as possible, however this would make it more complicated which would completely defeat its purpose as an educational tool.
This article is part of a Series On Regular Expressions.
The Regular Expression Visualizer, Simulator & Cross-Compiler Tool
Published 2020-07-09 |
$20.00 CAD |
Regular Expression Character Escaping
Published 2020-11-20 |
How Do Regular Expression Quantifier Work?
Published 2020-08-18 |
Interesting Regular Expression Test Cases
Published 2020-07-09 |
How Regular Expression Alternation Works
Published 2020-08-18 |
Character Ranges & Class Negation in Regular Expressions
Published 2020-05-31 |
Guide To Regular Expressions
Published 2020-07-09 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|