I’m facing a problem with Regex… I had to match sharepoint URL.. I need to match the “shortest”
Something like:
http://aaaaaa/sites/aaaa/aaaaaa/
m = Regex.Match(URL, ".+/sites/.+/");
m.Value equals to the whole string…
How can I make it match
http://aaaaaaa/sites/aaaa/
and nothing else??
Thank you very much!
.+is greedy, so it will match as many characters as possible before stopping. Change it to.+?and the match will end as soon as possible: