使用正则表达式替换其他字符串 [英] Replacing strings within others using regex
本文介绍了使用正则表达式替换其他字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有以下字符串;
Hi,
Let's say I have the following string;
$('test')...;
$('test notatest')...;
$('test notatest notatest2')...;
alert('this test should not be replaced');
使用Regex替换'test'的最佳方法是什么与其他东西,只有它出现在$(...)内?
我尝试过:
---------------------------------------- -----------------------
What's the best way using Regex to replace 'test' with something else, only where it appears within $(...)?
What I have tried:
---------------------------------------------------------------
推荐答案
('test')...;
('test')...;
('test notatest')...;
('test notatest')...;
('test notatest notatest2')...;
alert('此测试不应该被替换');
('test notatest notatest2')...; alert('this test should not be replaced');
使用Regex替换'test'的最佳方法是什么与其他东西,只有它出现在
What's the best way using Regex to replace 'test' with something else, only where it appears within
中
这篇关于使用正则表达式替换其他字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文