Reputation: 5767
I have an application which needs to find and then process Urls which follow a pattern like this:
http://www.actuino.fr/projets/frankenblink
http://www.actuino.fr/projets/
http://www.actuino.fr/projets
I have the following pattern which almost works...
string pattern = @"http://www.actuino.fr/projets/?.*";
Unfortunately that pattern will grab all Urls with 'projets' in as like this
http://www.actuino.fr/projetsarduino
http://www.actuino.fr/projets_rasberry
Thank you for your time.
Upvotes: 1
Views: 118
Reputation: 174696
Use word boundary.
string pattern = @"http://www\.actuino\.fr/projets\b/?.*";
or
Positive lookahead Assertion.
string pattern = @"(?m)http://www\.actuino\.fr/projets(?=/|$)/?.*";
(?=/|$)
asserts that the previous token projects
must be followed by a /
or end of the line.
Upvotes: 3