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 to use regular replacement string by wxs in WeChat Mini Programs

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly shows you "WeChat Mini Programs wxs how to use regular replacement string", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "WeChat Mini Programs wxs how to use regular replacement string" this article.

What is wxs?

WeChat Mini Programs wxs WXS (WeiXin Script) is a set of Mini Program scripting language, combined with WXML, you can build the structure of the page.

WXS and JavaScript are different languages, have their own syntax, and are not consistent with JavaScript.

How to use regular expressions

How to use ordinary JS? here, using the RegExp object of JS, the g parameter is taken out.

String.replace (new RegExp (pattern,'g'), "b")

When you look at wxs, you need to use the getRegExp function to generate the regexp object. GetRegExp (pattern [, flags])

String.replace (getRegExp (pattern,'g'), "b")

There are other parameters besides g.

G: globali: ignoreCasem: multiline . For instance

For example, you need to replace-in 2019-10-06 23:34:41 with.

Ordinary JS

Var str = '2019-10-06 23:34:41 "; str.replace (new RegExp (' -','g'),'.)

Wxs

Str.replace (getRegExp ('-','g'),'.')

Output: 2019.10.06 23:36:45

The above is all the contents of the article "how to use regular replacement strings in wxs in WeChat Mini Programs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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