From f11f24cc063744569dae11c0ec4b4dfbbde7ca6e Mon Sep 17 00:00:00 2001 From: Lynda K Date: Mon, 1 Mar 2021 15:54:28 -0500 Subject: [PATCH 1/2] Update 01-regular-expressions.md The two paragraphs below might be hard for a novice to digest. My suggestions: - Move the example of the phone numbers to the beginning of the first paragraph to give the idea more concreteness. - Provide an example of a regex for finding those phone numbers. This seems necessary because they don't see actual regexs until the exercises. - Define a literal character and give an example using the phone number example. - Give example of a metacharacter using the phone numbers. - The example of the escape in the second paragraph is understandable if you know regex. Is this necessary here or could it come after some exercises? With an example and exercise? Regular expressions rely on the use of literal characters (example) and metacharacters (example). A metacharacter is any American Standard Code for Information Interchange (ASCII) character that has a special meaning. By using metacharacters and possibly literal characters, you can construct a regex for finding strings or files that match a pattern rather than a specific string. For example, say your organization wants to change the way they display telephone numbers on their website by removing the parentheses around the area code. Rather than search for each specific phone number (that could take forever and be prone to error) or searching for every open parenthesis character (could also take forever and return many false-positives), you could search for the pattern of a phone number. Since regular expressions defines some ASCII characters as "metacharacters" that have more than their literal meaning, it is also important to be able to "escape" these metacharacters to use them for their normal, literal meaning. For example, the period `.` means "match any character", but if you want to match a period then you will need to use a `\` in front of it to signal to the regular expression processor that you want to use the period as a plain old period and not a metacharacter. That notation is called "escaping" the special character. The concept of "escaping" special characters is shared across a variety of computational settings, including markdown and Hypertext Markup Language (HTML). --- _episodes/01-regular-expressions.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_episodes/01-regular-expressions.md b/_episodes/01-regular-expressions.md index 39b67fe0..0caed389 100644 --- a/_episodes/01-regular-expressions.md +++ b/_episodes/01-regular-expressions.md @@ -22,7 +22,9 @@ In library searches, we are most familiar with a small part of regular expressio - Match patterns that repeat any number of times. - Capture the parts of the original string that match your pattern. -Regular expressions rely on the use of literal characters and metacharacters. A metacharacter is any American Standard Code for Information Interchange (ASCII) character that has a special meaning. By using metacharacters and possibly literal characters, you can construct a regex for finding strings or files that match a pattern rather than a specific string. For example, say your organization wants to change the way they display telephone numbers on their website by removing the parentheses around the area code. Rather than search for each specific phone number (that could take forever and be prone to error) or searching for every open parenthesis character (could also take forever and return many false-positives), you could search for the pattern of a phone number. +Regex can also be useful for daily work. For example, say your organization wants to change the way they display telephone numbers on their website by removing the parentheses around the area code. Rather than search for each specific phone number (that could take forever and be prone to error) or searching for every open parenthesis character (could also take forever and return many false-positives), you could search for the pattern of a phone number. +For example: XXXX +Regular expressions rely on the use of literal characters and metacharacters. A metacharacter is any American Standard Code for Information Interchange (ASCII) character that has a special meaning. By using metacharacters and possibly literal characters, you can construct a regex for finding strings or files that match a pattern rather than a specific string. Since regular expressions defines some ASCII characters as "metacharacters" that have more than their literal meaning, it is also important to be able to "escape" these metacharacters to use them for their normal, literal meaning. For example, the period `.` means "match any character", but if you want to match a period then you will need to use a `\` in front of it to signal to the regular expression processor that you want to use the period as a plain old period and not a metacharacter. That notation is called "escaping" the special character. The concept of "escaping" special characters is shared across a variety of computational settings, including markdown and Hypertext Markup Language (HTML). From 320ed5062b513b92a056f7ea72f8f136d2ade03d Mon Sep 17 00:00:00 2001 From: Shari Laster Date: Fri, 28 Apr 2023 16:02:50 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Removing the placeholder for an example; this is flagged as an issue for a future update. --- _episodes/01-regular-expressions.md | 1 - 1 file changed, 1 deletion(-) diff --git a/_episodes/01-regular-expressions.md b/_episodes/01-regular-expressions.md index 0caed389..9c872c42 100644 --- a/_episodes/01-regular-expressions.md +++ b/_episodes/01-regular-expressions.md @@ -23,7 +23,6 @@ In library searches, we are most familiar with a small part of regular expressio - Capture the parts of the original string that match your pattern. Regex can also be useful for daily work. For example, say your organization wants to change the way they display telephone numbers on their website by removing the parentheses around the area code. Rather than search for each specific phone number (that could take forever and be prone to error) or searching for every open parenthesis character (could also take forever and return many false-positives), you could search for the pattern of a phone number. -For example: XXXX Regular expressions rely on the use of literal characters and metacharacters. A metacharacter is any American Standard Code for Information Interchange (ASCII) character that has a special meaning. By using metacharacters and possibly literal characters, you can construct a regex for finding strings or files that match a pattern rather than a specific string. Since regular expressions defines some ASCII characters as "metacharacters" that have more than their literal meaning, it is also important to be able to "escape" these metacharacters to use them for their normal, literal meaning. For example, the period `.` means "match any character", but if you want to match a period then you will need to use a `\` in front of it to signal to the regular expression processor that you want to use the period as a plain old period and not a metacharacter. That notation is called "escaping" the special character. The concept of "escaping" special characters is shared across a variety of computational settings, including markdown and Hypertext Markup Language (HTML).