Skip to content

Commit 42cc71e

Browse files
committed
docs: add details explanation of pangram regex
1 parent 3f992ea commit 42cc71e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

String/CheckPangram.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ const checkPangram = (string) => {
1010
}
1111

1212
/**
13-
* match all 26 alphabets using regex, with the help of:
14-
* Capturing Group
15-
* Character set
16-
* Negative lookahead
17-
* Dot & star
18-
* Numeric reference
13+
* Match all 26 alphabets using regex, with the help of:
14+
* Capturing group - () -> Groups multiple tokens together and creates a capture group for extracting a substring or using a backreference.
15+
* Character set - [a-z] -> Matches a char in the range a to z in case-insensitive for the 'i' flag
16+
* Negative lookahead - (?!) -> Specifies a group that can not match after the main expression (if it matches, the result is discarded).
17+
* Dot - . -> Matches any character except linebreaks. Equivalent to
18+
* Star - * -> Matches 0 or more of the preceding token.
19+
* Numeric reference - \{$n} -> Matches the results of a capture group. E.g. - \1 matches the results of the first capture group & \3 matches the third.
1920
*/
2021
return string.match(/([a-z])(?!.*\1)/gi).length === 26
2122
}

0 commit comments

Comments
 (0)