c# - Regex: Find pagenumber from partial matching urls -
as know, regex patterns create stomache turn first time see them (or 10th time since never went head first , learned it. quilty.). i'm reading upon it, since i'm on tight deadline i'll check here if can quicker , improve answer/explaination meanwhile.
i have url forum thread, , want scan through html , find lastly page thread.
so have 1 of next urls identifying thread in question:
https://www.somesite.com/forum/thread-93912* (absolute url thread) /forum/thread-93912 (relative url thread)and want values (integers) appear straight (next path) after of above "partial" match in html-document.
so of next hrefs located anywhere in html-document (the doc represented single string):
https://www.somesite.com/forum/thread-93912/34 https://www.somesite.com/forum/thread-93912/34/morestuffhere/whatevs /forum/thread-93912/34 /forum/thread-93912/34/somethingheretooi want extract number 34 (only 34), can parse int.
edit
okay, create simpler:
say have html in htmlstring
, , in string want find all numbers x appear after inputstring /forum/thread-93912
.
these appear in htmlstring
, , want extract numbers:
you don't need regex. utilize system.uri.segments
uri url = new uri("your url here"); console.writeline(url.segments[4]);
c# regex
No comments:
Post a Comment