Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Back reference of AS3 js regular expression

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report