I want to edit this link eSearch | Account Sign In
i want idx=0 to increment i will use i=i+1.
width=97 to 3000 and height=97 to 3000 will be static.
I want to edit this link eSearch | Account Sign In
i want idx=0 to increment i will use i=i+1.
width=97 to 3000 and height=97 to 3000 will be static.
Hi.
Look into using Regex.Replace()
This will let you set a pattern for βidx=(.*)&β, then you can replace it with the new number. If you get stuck, let us know where you have a problem understanding.
Regards.
do you know what is deleting it? Is it code you are using?
System.Text.RegularExpressions.Regex.Replace(ul, "idx=(.*)&β,β1β)
Add in the part from your pattern next to β1β, like this:
System.Text.RegularExpressions.Regex.Replace(ul, "idx=(.*)&β,"idx="+"1β+"&")
Then, you can replace β1β with a variable that you increment.
You can do the same thing for the weight and height.
tnx for the help. when i run this code &width=97 gets deleted
It might be the β(.*)β part of the pattern.
Try changing it to digits, like this:
System.Text.RegularExpressions.Regex.Replace(ul, "idx=[0-9]{1,4}&β,"idx="+"1β+"&")
cool it works .Let me try completing the rest.
Iβm using i=i+1 for increment the value. where should I place the i in this System.Text.RegularExpressions.Regex.Replace(ul, "idx=[0-9]{1,4}&β,"idx="+"1β+"&")
replace β1β with i.ToString
System.Text.RegularExpressions.Regex.Replace(ul, "idx=[0-9]{1,4}&β,"idx="+i.ToString+"&")
can u let how to change the width and height to 3000 also I ran this code
βSystem.Text.RegularExpressions.Regex.Replace(ul, βidx=[0-9]{1,4}&β,βwidthβ+β3000β+β&β)β
extra width is getting added
For width, you need to replace βidx=β to βwidth=β in each place
System.Text.RegularExpressions.Regex.Replace(ul, βwidth=[0-9]{1,4}&β,βwidth=β+β3000β+β&β)
For heigth, will be like this:
System.Text.RegularExpressions.Regex.Replace(ul, βheight=[0-9]{1,4}β,βheight=β+β3000β)
I left off the β&β next to height since itβs on the end.
If you run into problems you might instead place the & infront of the keyword, like this:
System.Text.RegularExpressions.Regex.Replace(ul, β&idx=[0-9]{1,4}β,β&idx=β+i.ToString)
System.Text.RegularExpressions.Regex.Replace(ul, β&width=[0-9]{1,4}β,β&width=β+"3000")
System.Text.RegularExpressions.Regex.Replace(ul, β&height=[0-9]{1,4}β,β&height=β+"3000")
Iβm not a regex guy (and your code from last post seems to do the job just fine), but it seems that the start of the URL is static and the rest is either changed or iterated upon.
Wouldnt it be easier at this point to drop regex and use string formatting?
Something like:
string completeUrl = String.Format("https://cotthosting.com/NYOnondagaExternal/HTML5Viewer/wscottfilexfer.asmx/LoadThumbnail?requestID=4d48fb31-1d1d-4c10-9997-193a9189f762&idx={0}&width={1}&height={2}", idx, width, height)
idx width and height can be int variables.
If beginning also changes, that could be good for regex (get all before &idx).
What do you think?
Yeah good point @andrzej.kniola, but I was assuming his url already had the values in the url, so using Regex was a way to find those values in the url without knowing them.
lol, by the way, you might use the Snipping tool, which is software you can use to take screenshots.
Your idx value is 0, you need to add 1 to it. So instead of i.ToString change it to (i+1).ToString
, or change how you are incrementing it so it starts on 1 instead of zero.
Hope that helps.
If requestID would also be part of the format call, it pretty much becomes filling the blanks game. Or combine both approaches to get values out and reconstruct the URL.
In any case, a pure regex approach will be more flexible, but in the long run someone has to support it and debugging that can be pretty hard if one is not versed in regex (I know Iβm not so I try to avoid complex regexes).
Oh I understand, so basically store the entire url to a string in your code, then you just play the replace game.
yeah exactly.