Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the meaning of the regular expression / ig in javascript

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what is the meaning of regular expression / ig in javascript". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the meaning of regular expression / ig in javascript".

In JavaScript regular expressions, "/ ig" means "perform a global match and ignore case" and is a modifier, where the modifier "I" is used to indicate the execution of a case-insensitive match, and the modifier "g" is used to indicate that a global match is performed.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What does the regular expression / ig mean in javascript

The difference and meaning of / iMagnequence in regular expressions

/ I (ignore case)

/ g (full text search for all matching characters that appear)

/ m (multiline lookup)

/ gi (full text search, ignore case)

/ ig (full text search, ignore case)

Modifier

The modifier describes that I performs a case-insensitive match. G performs a global match (looking for all matches instead of stopping after the first match is found). M performs multi-line matching.

Square bracket

Square brackets are used to find characters in a range:

The expression describes [abc] to find any character between square brackets. [^ ABC] look for any characters that are not between square brackets. [0-9] look for any number from 0 to 9. [aMuz] finds any character from lowercase a to lowercase z. [Amurz] looks for any character from uppercase A to uppercase Z. [Amurz] looks for any character from uppercase A to lowercase z. [adgk] finds any character within a given collection. [^ adgk] finds any character outside a given collection. (red | blue | green) find any specified options.

Metacharacter

Metacharacters (Metacharacter) are characters with a special meaning:

Metacharacter description. Look for a single character, except for line breaks and line Terminators. W look for word characters. W looks for non-word characters. D look for numbers. D looks for non-numeric characters. S looks for white space characters. S looks for non-white space characters. B find the match at the beginning or end of the word. B look for matches that are not at the beginning or end of the word.

Look for NUL characters. N look for newline characters. F find the feed character. R look for carriage returns. T look for tabs. V look for vertical tabs. Xxx looks for the characters specified by the octal number xxx. Xdd looks for characters specified by the hexadecimal number dd. Uxxxx looks for Unicode characters specified by the hexadecimal number xxxx.

Quantifier

The quantifier description n + matches any string that contains at least one n. N * matches any string that contains zero or more ns. N? Matches any string that contains zero or one n. N {X} matches a string containing a sequence of X n. N {XQuery Y} matches a string containing a sequence of X or Y n. N {X,} matches a string containing a sequence of at least X n. N $matches any string that ends with n. ^ n matches any string that starts with n. ? = n matches any string followed by the specified string n. ?! n matches any string that is not followed by the specified string n.

RegExp object Properties

FF: Firefox, IE: Internet Explorer

Property describes whether the FFIEglobalRegExp object has a flag g. Whether the 14ignoreCaseRegExp object has a flag I. 14lastIndex an integer indicating the position of the character at which the next match begins. Whether the 14multilineRegExp object has the flag m. The source text of the 14source regular expression. fourteen

RegExp object method

FF: Firefox, IE: Internet Explorer

Method describes how FFIEcompile compiles regular expressions. 14exec retrieves the value specified in the string. Returns the value found and determines its location. 14test retrieves the value specified in the string. Returns true or false. fourteen

Methods of String objects that support regular expressions

FF: Firefox, IE: Internet Explorer

Method describes how FFIEsearch retrieves a value that matches a regular expression. 14match found a match for one or more regular expressions. 14replace replaces the substring that matches the regular expression. 14split splits a string into an array of strings.

Thank you for reading, the above is "what is the meaning of regular expression / ig in javascript", after the study of this article, I believe you have a deeper understanding of what the meaning of regular expression / ig in javascript is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report