Detailed explanation of regular expressions for Javascript learning

 

What is a regular expression (regular expreSSion)

  A regular expression is an object that describes a pattern of characters.

  Can handle more complex strings

  Regular expressions in JavaScript are represented using RegExp objects

  Regular expressions are used for pattern matching and retrieval and replacement of strings, and are powerful tools for performing pattern matching on strings.

  How to use regular expressions in JavaScript

  grammar

  var patt=new RegExp(pattern,modifierS)

  Dynamically create regular expressions

  var patt = / pattern / modifierS;

  parameter

  pattern ( pattern ) describes the pattern of the expression

  modifierS is used to specify global matching , case-sensitive matching, and multi-line matching

  Common modifiers

  Modifiers are used to perform case-sensitive and glob matching

 

 

  Square brackets

  Square brackets are used to find characters within a range



 

  metacharacter

  Metacharacters are characters with special meanings



 

  quantifier 



Original link: http://www.maiziedu.com/wiki/js/regexp1/

 

<!--EndFragment-->

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326464591&siteId=291194637