NSE4 · Question #185
Which of the following Regular Expression patterns will make the term "bad language" case insensitive?
The correct answer is B. /bad language/i. In regular expressions, the 'i' flag appended after the closing delimiter makes the pattern match case-insensitively.
Question
Which of the following Regular Expression patterns will make the term "bad language" case insensitive?
Options
- A[bad language]
- B/bad language/i
- Ci/bad language/
- D"bad language"
- E/bad language/c
How the community answered
(41 responses)- A7% (3)
- B88% (36)
- C2% (1)
- E2% (1)
Why each option
In regular expressions, the 'i' flag appended after the closing delimiter makes the pattern match case-insensitively.
`[bad language]` is a character class that matches any single character present within the brackets, not the entire phrase 'bad language' case-insensitively.
The `/pattern/i` syntax is a widely adopted convention in regular expressions, where the 'i' flag at the end signifies that the pattern should be matched without regard to case (case-insensitively).
The 'i' flag for case-insensitivity is appended after the closing forward slash, not placed before the opening one.
`"bad language"` is a literal string and does not employ regular expression syntax to achieve case-insensitive matching.
The `/c` flag is not a standard regular expression flag for case-insensitivity; the correct flag for this purpose is 'i'.
Concept tested: Regular expression case-insensitivity flag
Source: https://docs.fortinet.com/document/fortimanager/7.0.0/admin-guide/700818/regex-for-matching-content
Topics
Community Discussion
No community discussion yet for this question.