Hello,
I'm trying to take a long URL string and make a change to part of it using Regular Expressions.
Here is an example of part of the string to change:
"property+address%22%0a&start=100&rows=200&fl=doc_id%2c+doc_cmt_description&wt=csv&indent=true>"
I need to be able to change the following parts of the string:
start=100 AND rows=200
I just need to be able to change the numbers. It is unknown how many digits would in these so I figured regular expressions would be the best, but the pattern part to change it is tough. With what I have, it removes the start= and rows=, but does not fill them in at the correct spot in the string.
I'm trying to take a long URL string and make a change to part of it using Regular Expressions.
Here is an example of part of the string to change:
"property+address%22%0a&start=100&rows=200&fl=doc_id%2c+doc_cmt_description&wt=csv&indent=true>"
I need to be able to change the following parts of the string:
start=100 AND rows=200
I just need to be able to change the numbers. It is unknown how many digits would in these so I figured regular expressions would be the best, but the pattern part to change it is tough. With what I have, it removes the start= and rows=, but does not fill them in at the correct spot in the string.
C#:
int startRows = 0;
int getRows = 500;
string firstReplacement = "start=" + startRows;
string secondReplacement = "rows=" + getRows;
string firstPattern = "start=.*&";
string secondPattern = "rows=.*&";
Output = Regex.Replace(Input, firstPattern, firstReplacement, RegexOptions.IgnoreCase);
Output = Regex.Replace(Input, secondPattern, secondReplacement, RegexOptions.IgnoreCase);