Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Back reference of AS3 js regular expression

Shulou Source: shulou.com Published: 2022-06-02 04:12:30 09月24日 Update

This article mainly talks about "reverse quotation of AS3 js regular expressions". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the reverse reference of AS3 js regular expressions".

As3 Code:

Var str = ""; var reg = / (\ d {})\ / gx; / / is a reverse grouping, representing the same matching result characters in the previous group. If\ d {} matches, then\ can only be a match, var first=str.match (reg) / / match () returns an object. If reg has a global attribute g, the numeric index of the object is each exact matching character. / / if there is no global attribute g, the index is the first exact matching character. The other indexes are each group matching character for (var key in first) {trace ("first attribute name:" + key + ", value:" + first [key])] / * output first attribute name:, value: first attribute name:, value: * /

Js code

Var str = ""; var reg = / (\ d {})\ / gx; / / is a reverse grouping, representing the same matching result characters in the previous group. If\ d {} matches, then\ can only be a match, var first=str.match (reg) / / match (), returns an object. If reg has a global attribute g, the numeric index of the object is each exact matching character, / / if there is no global attribute g, the index is the first perfect matching character, and the other indexes are each group matching character for (var key in first) {[xss_clean] ("first attribute name: + key +", value: + first [key])}.

A more complex backreference:

Here is a simple keyword search highlighted regular expression usage.

AS3

Var str = "; var reg = / (\ d {})\ / gx; var first=str.replace (reg," $$"); / / output $$. The function of / / replace () is to replace the matching string with the corresponding field. / / Note that $reverse represents the grouping\ d {} in the first parenthesis of reg, while $is directly displayed, indicating that the regular expression only recognizes parentheses as grouping and does not recognize / as the second grouping trace (first).

JS

Var str = "; var reg = / (\ d {})\ / gx; var first=str.replace (reg," $$"); / / output $$. The function of / / replace () is to replace the matching string with the corresponding field. / note that $reverse represents the grouping\ d {} in the first parenthesis of reg, while $is directly displayed, indicating that the regular expression only recognizes parentheses as grouping and does not recognize / recognize as the second grouping [xss_clean] (first). At this point, I believe you have a deeper understanding of the "reverse reference of AS3 js regular expressions", you might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Grouping characters attributes regular first time Index expression Representative Global object parenthesis output same Code function content Field string number result Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology vpn NVidia Xiaomi MariaDB