I would like to ask all the bosses.
Why does console.log (/ (? = ^ a) bd/.test ("abd,bcd")) / / print out false. Maybe I don"t understand this thing well enough
I would like to ask all the bosses.
Why does console.log (/ (? = ^ a) bd/.test ("abd,bcd")) / / print out false. Maybe I don"t understand this thing well enough
look forward to find out whether
= an is followed by an and? = ^ means the beginning, so it's false
/ (? < = ^ a) bd/.test ('abd,bcd')
so it is true
I remember that general regular symbols match one or more characters, while these forward-looking rules match one position. Imagine that there is a cursor flashing before and after each character of the string to be matched, and these cursors are what I'm talking about.
(? = exp) matches a position that is followed by exp
(?! exp) matches a position, this position is not followed by exp
(? < = exp) matches a position, this position is preceded by exp
(? .
(? = ^ a) bd
means:
first matches a cursor position, which must be followed by a string followed by a
followed by bd
so there is a contradiction here. There can never be a string that satisfies this regularity. A position is followed by ^ an and bd.
vice versa bd (? = a)
is right, matching db is followed by a position, which must be followed by a.
(? < = ^ a) bd
also explains that it matches a position that must be preceded by the beginning + a, followed by bd.
is this analysis easy to understand? You don't have to remember whether the parentheses are put before or after. Remember that they match a cursor position on OK. This is what the zero width assertion
means that they match a cursor position without length. Haha
1. The string str= "zz=aaa,bb=bbb,cc=ccc;User=ZZZ&zz=aaa1&bb=bbb1&cc=ccc1 " 2. To implement, for example, I pass in the parameter zz, and find the value of aaa1 in the zz=aaa1 after User=ZZZ. How to write the corresponding rule? ...
^ (18 [0-9] {9}) | (15 [0-9] {9}) $ Why the rule matches 1844444444444444 . My understanding of this rule is starting with 18 or 15 followed by 9 digits 0-9 . Note: I know there are other ways to write the rules of mobile phone numbers. I just ...
The range of characters is text, letters, numbers and "( ", ") ", "[ ", "] ", "space "; how should the rule of up to 20 words be written ...
need to match: https: www.example.com https: www.example.com demo https: www.example.com demo abc https: www.example.com demo abc 123.html () mismatch: https: www.example.com demo abc efg123.html ...
1. The string in the cookie fetched by the foreground is a connection of multiple cookie, for example, these two types: var str = "OnlineCookie=OnlineCookie&UserType=11111111111111111&UID=39&UserName=; UID=; UserType=; UserName=";...
MEDU1778421 FEJ7296886 FCIU2741867 FEJ7296887 GLDU9472098 FEJ7296888 I want to match the following numbers and replace them with spaces for example, how to match letters and spaces MEDU1778421 FCIU2741867 GLDU9472098 ...
as shown in the figure: I use str.replace ( (null) , "jsonCallBack "); can only replace the first null, , but what should I do to replace the third? the following is the string "< input type= " radio "name= " p_date_type_sl_sl_sl "value= " i...
var newsname; ctrl.checkNameLegal = function () { if (ctrl.fileName) { var exports = ^(?![.])[ u4e00- u9fa5_.a-zA-Z0-9]+$ ig; if (exports.test(ctrl.fileName)) { newsname = ctrl.fileName; } else { ctrl.fileName = newsname; } } else { newsname = ...
when trying to use regular matching 12-128, it is found that it can match to 129, such as the question. 192.168.0.(12[0-8]|1[0-1][0-9]|[2-9][0-9]|1[2-9]) True is returned when matches 129. judgment 255 will also match the first two digits 25. h...
1. Requirements: write a regular 2 that can automatically add a space for every 4 digits written. Problem: the regular (or incorrect) is written out, but the spaces cannot be deleted! 3. Picture 4. Code innput listening: `$("ul.information-...
const datas =[ "https: img.codeshelper.com upload img 2021 03 09 1tcsu5c0vun5800.png", "https: img.codeshelper.com upload img 2021 03 09 mc3p5hxjed25801.png", "https: img.codeshelper.com upload img 2021 03 09 b0sxs...
*start* import aaa ; *end* let a={ b: c *start* d: e *end* } now you want to match all the content from * start* to * end* , and replace it with ", , that is, all that s left in the above code is: . let a={ b:...
A HTML in a text box contains text and img tags for example <img src=".. .. static images express 4.gif" alt="[em_4]"><img src=".. .. static images express 4.gif" alt="[em_4]"> make Filter look like...
the following regular expression can successfully configure key, (^ |) in url. Doesn t it mean start or empty? how can it match & what s wrong with it? regular ?ie=utf-8&f=8&rsv_bp=0&rsv_idx=1&tn=baidu&wd=%E6%AD%A3%E5%88%99%E8%A1...
as shown in the figure above: in the first way, the $3.23 is identified as false , but in the second way, only one parameter g is removed and passed. According to principle, the first one should also be passed, please give us guidance! ...
example: (999 < video > < video > ) I want to delete the p tag in parentheses (). ...
find the underscore through the regular expression, return the previous content, and don t want anything else. ...
password requires 1, number 2, letter 3, number + letter ...
Code first: if( ( module (?:.+[^ .html])) .test(". src module comment details.html")){ console.log(RegExp.$1) module comment details } if( ( module (?:.+[^ .js])) .test(". src module comment details.js")){ console...
for example: abdsdsdfsdf1526614206112164350fskdfskdf1526614199681037404bcmvbcvbmcnvz: match 1526614206112164350 and 1526614199681037404 in the string, add quotation marks on both sides, and process it as follows: abdsdsdfsdf "1526614206112164350 " fskdf...