Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

New flag in regular expressions:d#3552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Alexandre887 wants to merge1 commit intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromAlexandre887:master-14
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions9-regular-expressions/01-regexp-introduction/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,9 +39,9 @@ let regexp = new RegExp(`<${tag}>`); // same as /<h2>/ if answered "h2" in the p

## Flags

Regular expressions may have flags that affect the search.
Regular expressions may have flags that affect the search or provide additional information.

There are only6 of them in #"7582e64a723e6ca5aa35167c707cf105b3263c5d5d00b92913e6522b570a0d4e">There are only7 of them in #"7582e64a723e6ca5aa35167c707cf105b3263c5d5d00b92913e6522b570a0d4e">
`pattern:i`
: With this flag the search is case-insensitive: no difference between `A` and `a` (see the example below).
Expand All@@ -61,6 +61,9 @@ There are only 6 of them in #"c57cdff087f3f7e5461a1c15f562f5ea3414e0dd347333c25874f2ee7154ac49">`pattern:y`
: "Sticky" mode: searching at the exact position in the text (covered in the chapter <info:regexp-sticky>)

`pattern:d`
: With this flag, the result of the regular expression is placed in an array which contains additional information about the regular expression, such as the start and end indices of the substring. This flag does not change the behavior of the regular expression, it just provides additional information.

```smart header="Colors"
From here on the color scheme is:

Expand DownExpand Up@@ -170,7 +173,7 @@ Full information about the methods is given in the article <info:regexp-methods>

## Summary

- A regular expression consists of a pattern and optional flags: `pattern:g`, `pattern:i`, `pattern:m`, `pattern:u`, `pattern:s`, `pattern:y`.
- A regular expression consists of a pattern and optional flags: `pattern:g`, `pattern:i`, `pattern:m`, `pattern:u`, `pattern:s`, `pattern:y`, `pattern:d`.
- Without flags and special symbols (that we'll study later), the search by a regexp is the same as a substring search.
- The method `str.match(regexp)` looks for matches: all of them if there's `pattern:g` flag, otherwise, only the first one.
- The method `str.replace(regexp, replacement)` replaces matches found using `regexp` with `replacement`: all of them if there's `pattern:g` flag, otherwise only the first one.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp