i am asking the question which can be answered by a small attempt in googling but i am not finding anything which can do this, so i am asking here. pls dont downvote and close it, it can be useful for others also:
my problem is: i need to look for some portion of string, and find that and replace that. but my problem is that that portion of string is changing everytime, so i need to inject some regexp.
$url = "www.google.com/test=2";
replace the 'test=2' with 'test=1'
$result = "www.google.com/test=1"
the thing is: the slug can have any number between 1 - 20: test=\d{1,20} this is the case. i tried preg_replace, substr_replace but none of them can do this.