From 46af8e3ea07bb1f03304e8558c7747ff24da6228 Mon Sep 17 00:00:00 2001 From: Falak Date: Tue, 1 Aug 2017 16:29:35 +0530 Subject: [PATCH] Fix #27 and grammatical fixes * Addressing Hashtags and @mentions Added both cases in the bonus section * Minor grammatical fixes Fixes to issue #27 --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1a9ba3d..17f8811 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ the comma the regular expression `[0-9]{3}` means: Match exactly 3 digits. ## 2.5 Character Group Character group is a group of sub-patterns that is written inside Parentheses `(...)`. As we discussed before that in regular expression -if we put a quantifier after a character than it will repeat the preceding character. But if we put quantifier after a character group then +if we put a quantifier after a character then it will repeat the preceding character. But if we put quantifier after a character group then it repeats the whole character group. For example, the regular expression `(ab)*` matches zero or more repetitions of the character "ab". We can also use the alternation `|` meta character inside character group. For example, the regular expression `(c|g|p)ar` means: lowercase character `c`, `g` or `p`, followed by character `a`, followed by character `r`. @@ -328,7 +328,7 @@ regular expressions. The shorthand character sets are as follows: Lookbehind and lookahead sometimes known as lookaround are specific type of ***non-capturing group*** (Use to match the pattern but not included in matching list). Lookaheads are used when we have the condition that this pattern is preceded or followed by another certain pattern. For example, we want to get all numbers that are preceded by `$` character from the following input string `$4.44 and $10.88`. -We will use following regular expression `(?<=\$)[0-9\.]*` which means: get all the numbers which contains `.` character and preceded +We will use following regular expression `(?<=\$)[0-9\.]*` which means: get all the numbers which contain `.` character and are preceded by `$` character. Following are the lookarounds that are used in regular expressions: |Symbol|Description| @@ -482,7 +482,8 @@ line. And because of `m` flag now regular expression engine matches pattern at t * *Date (MM/DD/YYYY)*: `^(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}$` * *Date (YYYY/MM/DD)*: `^(19|20)?[0-9]{2}[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])$` * *MasterCard credit card numbers*: `^(5[1-5][0-9]{14})*$` - +* *Hashtags*: Including hashtags with preceding text (abc123#xyz456) or containing white spaces within square brackets (#[foo bar]) : `\S*#(?:\[[^\]]+\]|\S+)` +* *@mentions*: `\B@[a-z0-9_-]+` ## Contribution * Report issues