How to use RegExp Replace to replace an offer?

How to use RegExp Replace to replace below words?

-

(1) Replace / delete what ever started 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 / Delete what ever started 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 ~~~

+5
source share
1 answer

(1):

var replaced = string.replace(/a.*?c/gi, "");

(2):

var replaced = string.replace(/(.*?)xyz=&(.*?)/gi, "$1,$2");

The above example uses Javascript. But the common regex will be the same in all regex aromas.

+3
source

All Articles