Skip to content

Commit 3b9b645

Browse files
RobinJavaaDevsumn2u
authored andcommitted
fix(docs): resolve syntax errors and typos in regular-expression.md (#290)
1 parent 1b570ad commit 3b9b645

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

β€Žen/regular-expression.mdβ€Ž

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A regular expression is an object that can either be constructed with the `RegEx
1515
new RegExp(pattern[, flags]);
1616

1717
// using literals
18-
/pattern/modifiers
18+
/pattern/flags
1919
```
2020

2121
The flags are optional while creating a regular expression using literals. Example of creating identical regular using above mentioned method is as follows.
@@ -39,7 +39,7 @@ Example :
3939

4040
```javascript
4141
const str = "Hello world, hello again!";
42-
const regex = /hello/g;
42+
const regex = /hello/gi;
4343
const matches = str.match(regex);
4444
// If you are thinking about .match() Read This πŸ‘‡
4545
// It is a built-in method in JavaScript that is used to search a string for a match against an expression.
@@ -175,11 +175,11 @@ _Metacharacters_ are special character that has special meaning in the regular e
175175

176176
| Metacharacter | Description |
177177
| ------------- | ---------------------------------------------------------------- |
178-
| `.` | Match a single character excpet newline or a terminator |
178+
| `.` | Match a single character except newline or a terminator |
179179
| `\w` | Match a word character (alphanumeric character `[a-zA-Z0–9_]`) |
180180
| `\W` | Match a non word character (same as `[^a-zA-Z0–9_]`) |
181181
| `\d` | Match any digit character( same as `[0-9]`) |
182-
| `\D` | Match any non digiti character |
182+
| `\D` | Match any non digit character |
183183
| `\s` | Match a whitespace character (spaces, tabs etc) |
184184
| `\S` | Match a non whitespace character |
185185
| `\b` | Match at the beginning / end of a word |
@@ -219,7 +219,7 @@ let text = "The best things in life are free";
219219
let result = /e/.exec(text); // looks for a match of e in a string
220220
// result: e
221221

222-
222+
console.log(result); // Result: ["e", 2, "The best things in life ar..."]
223223
let helloWorldText = "Hello world!";
224224
// Look for "Hello"
225225
let pattern1 = /Hello/g;

0 commit comments

Comments
Β (0)