-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve introductory text to regex #187
Comments
I think the phone number example could work if the \d metacharacter is briefly introduced and you restrict the context a little. For example, if you know ahead of time that a phone number you're trying to match is definitely in (xxx) xxx-xxxx format, you could demonstrate matching this with the regex pattern I think this would work best if accompanied by a diagram showing the distinction within this pattern between literal characters and metacharacters, something like the following: This only involves literal characters, one metacharacter, and escaping. You can state that this will only match numbers in the above format, not xxx xxx xxxx, (xxx) xxx xxxx, xxxxxxxxxxx, etc. to express the power of regular expressions to be very selective in matching. It could also be useful to note that, later on, learners will see that regexes are sufficiently expressive to capture many different phone number formats while excluding non-phone-number strings of digits. If folks wanted to use a different example, I think an example of similar complexity (mix of literals, one or two metacharacters, and optionally escaping) is best, along with a visual that clarifies what the metacharacters are "doing" in the regex. |
@mclenard I really like this proposed solution! Before we move forward on adding this, do you have ideas or resources that could help create a version of your proposed diagram that meets accessibility criteria so it is still useful to folks who use a screen reader or other assistive technology? |
Ahh, good question. I'm not so versed in that, but that is an important consideration I forgot to address. As a very basic nod toward accessibility, I think you could try and express it in alt-text, maybe something like |
In #184, @lyndamk suggests revising several introductory paragraphs to make them easier for a novice to digest. I agree this is a good idea! The PR is a great start, and just needs some expert eyes to suggest a regex example that works for the given context.
The text was updated successfully, but these errors were encountered: