first, that is not an empty string
second, parentheses denote "capture" in the regular, such as '123abc'.replace (/ (\ d +) abc/,' $1')
where $1
indicates the matching content in the first parenthesis, that is, 123
.
third, in this case, to clarify the problem, change to 'a'.match (/ () a /)
, and the result will be ["a", ", index: 0, input:" a ", groups: undefined]
. The first element in the result is all the strings matched by the regular expression () a
, and the second element is the result of the first" capture " ()
. This means word boundary , which is equivalent to \ b
in regular expressions.
back to the topic, the writing in the title is equivalent to '.match (/ (\ b) /)
. Since the body of the regular expression is only captured, the first element in the result is the same as the second element, which looks like an "empty string" but is actually not "empty". Please compare with the third point to understand.
Previous: Isn't false the default for the property tag of the javascript object?
Next: Can Mini Program long press to identify the official account QR code?
hello big red cat hello big red dog hello yellow bird hello 123 555 blue cat and dog ... in a paragraph of text, I need to match to hello big red cat hello 123 555 blue cat this is how I wrote these two sentences hello[ s S]*cat$ results match all...
? & ab&cd&ef matching rules [&] {0jue 1} ab and [&] {0jue 1} cd replacement characters are empty but the results of the two machines are different: one is? & ef, and the other is normal? & ef is it because {0jimi 1} to match? ...
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? ...
for example, a string: American (United States of) to extract: (United States of) or Abcde (Df WD asdAS ASDW) to extract: (Df WD asdAS ASDW) to use regular expressions Thank you guys ...
$res = preg_match_all( src="(.+ .(png|jpg))"+? , <img src=" Public attached image 20170227 20170227143202_25223.jpg" alt="" ><img src="Public attached image 20170227 20170227143202_25223.jpg" alt=&...
recently learned python regular expressions, want to use regular expressions to extract the specified string in multiple lines I have been searching the Internet for a long time, and there are a lot of people asking questions on the Internet, but they...
question: take out the values of status and request_time in the log: this log cannot be matched by script: {"@timestamp":"2018-03-30T19:24:26+08:00","server_addr":"172.31.0.24","remote_addr":"10....
question: enter parameters of two arbitrary integers, such as 88-3333, and return a regular expression that matches all values in the range. A problem that looks simple at first, but then finds that the implementation is too complex (not sure whether it...
use reg = (? < = mileage). (re.findall: km | km (?! ) | (em: km | km (?! ). (? = mileage) the method is re.findall the text above is input the list below is output for example, for the first one, I only need to take 34km , for example, fo...
:span : <span style="color:red">< span><span>good< span> :<span style="color:red">< span><span>good< span> ...
demand background: A background system of the company. The form page is paged with ajax. After clicking on the page, you want the current url to record the paging information, so that when you refresh the current page, the paging information will not ...
^ [Amurz]. {4,} [Amurz] $ this is OK (^ [Amurz]. * [Amurz] $) {6,} it is not possible to ask why I require the length of the whole expression as a whole to reach 6 digits ....
guys, I want to use a regular expression to match 15-bit, 18-bit, and alphabetic ID numbers in a bunch of strings. The pile of strings is as follows: | _ Potentially risky methods: TRACE | _ http-server-header: 2.4.23 (Win32) OpenSSL 1.0.2j PHP 5.4...
(?!) Zero width negative antecedent assertion, attempts to match always fail because there is no suffix expression how to understand this sentence. If you can give an example. ...
^ (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 ...
such as title: find a numerical regular expression that ends with n zeros. Thank you ...
<span style="text-align: justify; font-size: 114px;"><span> <span style="text-align: justify; font-size: 114px;"><span> as in the text above, I want to get all the values with px set. I originally wrote Patte...
The range of characters is text, letters, numbers and "( ", ") ", "[ ", "] ", "space "; how should the rule of up to 20 words be written ...
^ s+| s+$ ^( s+)| 1$ ^[A-Z]| [A-Z]$ ^([A-Z])| 1$ I don t know where to understand the problem, the problem of symbol priority? Or something else, if anyone can answer, thank you very much. ...
The expression in the question is a little unclear: specifically, the reason is a malfunction of the CPU circuit board and needs to be replaced. B= CPU circuit board import re C = re.search (A Magi B) print (C) how to get the index value of CPU c...