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

How JS regular expressions get strings after and before specified characters

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Editor to share with you how the JS regular expression gets the string after the specified character and before the specified character, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.

A common scene, get: tag background picture link:

For example, the string var bgImg = "url"

(\ "https://cache.yisu.com/upload/information/20201208/267/25728.jpg\")";

Script:

Var backgroundImageRegex=/ (? 0) {alert (matchResult [0]);}

Highlight:

0-Special character: () "these three need to be escaped

1-after getting the specified string: (?

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