[Solved] replace the matched expression from string and its next charecter?POST operation


You may want to try out the following regex. Regex101 link

((?:\?.*?&|\?)journey=)[^&]*

Try out the following code to replace the value of journey to replacement

string url = "http://www.whitelabelhosting.co.uk/flight-search.php?dept=any&journey=R&DepTime=0900";
string newUrl = Regex.Replace(url, @"((?:\?.*?&|\?)journey=)[^&]*", "$1"+"replacement");

Remember to add the following to your file:

using System.Text.RegularExpressions;

You can do the same for DepTime using the following regex:

((?:\?.*?&|\?)DepTime=)[^&]*

1

solved replace the matched expression from string and its next charecter?POST operation