You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. The first search returns `-1` (not found), because the search is case-sensitive by default.
120
-
2. With the flag `pattern:/LOVE/i` the search found `match:love` at position 2.
117
+
alert( str.search(/LOVE/) ); // -1 (nothing found without 'i' flag)
118
+
```
121
119
122
120
So the `i` flag already makes regular expressions more powerful than a simple substring search. But there's so much more. We'll cover other flags and features in the next chapters.
123
121
124
122
125
123
## Summary
126
124
127
-
- A regular expression consists of a pattern and optional flags: `g`, `i`, `m`, `u`, `y`.
125
+
- A regular expression consists of a pattern and optional flags: `g`, `i`, `m`, `u`, `s`, `y`.
128
126
- Without flags and special symbols that we'll study later, the search by a regexp is the same as a substring search.
129
-
- The method `str.search(regexp)` returns the index where the match is found or `-1` if there's no match.
127
+
- The method `str.search(regexp)` returns the index where the match is found or `-1` if there's no match. In the next chapter we'll see other methods.
0 commit comments