diff --git a/Regular Expressions/Published-Topics.md b/Regular Expressions/Published-Topics.md index e69de29..bfd8698 100644 --- a/Regular Expressions/Published-Topics.md +++ b/Regular Expressions/Published-Topics.md @@ -0,0 +1 @@ +bharat soni \ No newline at end of file diff --git a/Regular Expressions/Regular Expressions - Cheat Sheet.md b/Regular Expressions/Regular Expressions - Cheat Sheet.md new file mode 100644 index 0000000..6cdb8e6 --- /dev/null +++ b/Regular Expressions/Regular Expressions - Cheat Sheet.md @@ -0,0 +1,35 @@ +# Regular Expressions - Cheat Sheet + +* use a single `|` to say 'or' +* `[ ]` - says any of the characters inside the brackets +* `?` make the preceding token optional +* `.+` - matches all characters to the end of the line +* use parentheses to group characters as using the `|` alone divide the regex into only a left and right side. +* `^` matches only if it's at the beginning of a string +* `$` matches only if it's the end of a string +* `+` is greedy - it won't just get the next token. it will keep searching until it reaches the last one. +* `+?` is not greedy - it will just search to the next occurrence of a token. +* `{3}` - would match 3 occurrences of the preceding token +* `{3,4}` - could match the range of 3 to 4 characters of the preceding token + +## Flags +* `\w` - matches any word character +* `\r` = carriage return +* `\n` = new lines +* `\s` = space characters +* `\w` = word character +* `\d` = digits 0-9 + +## Lookahead and Lookbehind +* `(?