How do I use RegExp Replace to replace sentence?
How do I use RegExp Replace to replace below word?
--
(1) Replace/Remove what ever word start with "a" and end with "c"!开发者_高级运维
Example (1): abc, xyz, axc, bbb, ccc ayc, a1c, abcc, axxyzc...
Replace after (1): , xyz, , bbb, ccc , , , ...
--
(2) Replace/Remove what ever word start with "abc=" and end with "&"!
Example (2): abc=123&xyz=111&abc=xgggf&abc=ffff&abc=xxxx&xyz=kkk&abc=zzz&
Replace after (2): xyz=111&xyz=kkk&
--
Thanks~~~
(1):
var replaced = string.replace(/a.*?c/gi, "");
(2):
var replaced = string.replace(/(.*?)xyz=&(.*?)/gi, "$1,$2");
The above is using Javascript. But the general regex's will be the same in all regex flavors.
精彩评论