JS regular expression character matching

Regular expression character matching This is some notes after reading “Javascript Regular Expression Mini Book”. Regular expressions are matching patterns that can match characters and positions. The following mainly introduces the situation of matching characters, and I am also learning the situation of matching positions. Two kinds of fuzzy matching: 1. Horizontal fuzzy matching: The length of a regular string that can be matched is not fixed of. This is achieved by using quantifiers. For example, {m,n} means that the character appears at least m times and at most n times. For example, /ab{2,5}c/ means to match such a string: the first character is “a”, followed by 2 to 5 characters “b”, and finally the character “c “. For example: (You can try it manually and think about the results you will get) var regex = /ab{2,5 }c/g; var string = “abc abbc abbbc abbbbc abbbbbc abbbbbbc”; console.log( string.match(regex) ); g is a modifier, which means global matching, which is to find all the strings that meet the matching conditions in order in the string. 2. Vertical fuzzy matching: A regular matchable string is specific to a certain character, it may not be a definite character, and there may be…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索