简体   繁体   English

正则表达式

[英]Regular expression

I have text from regular expression:我有来自正则表达式的文本:

This post contains forecast for BTC/USDC This message was written by guest user, and is available at site.com

I need add with regular expression dot before like this: "BTC/USDC. This message" .我需要像这样添加正则表达式点: "BTC/USDC. This message" How can i do that?我怎样才能做到这一点?

You can use String.prototype.replace() by providing a regex to find BTC/USDC and then return the string with the updated data using callback pattern您可以通过提供正则表达式来使用String.prototype.replace()来查找BTC/USDC ,然后使用回调模式返回带有更新数据的字符串

 var str= "This post contains forecast for BTC/USDC This message was written by guest user, and is available at site.com" const newStr= str.replace(/BTC\/USDC/, (match) => { return `${match}.`; }) console.log(newStr);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM