Ignore the optional greedy regex suffix

I am comparing regular expressions in .NET with strings that look like this:

1; # Lists / General Discussion / Waffles Win
2; # Lists / General Discussion / Waffles Win / 2_.000
3; # Lists / General Discussion / Waffles Win / 3_.000

I need to map the URL with no numbers at the end, so I get the following:

Lists / General Discussion / Waffles Win

This is the regular expression I'm trying:

(?: \ d +; #) (? <url>. +) (?: / \ d + _. \ d +) *

The problem is that the last group is included as part of the middle group match. I also tried without * at the end, but then only the first line is above the matches, not the rest.

I have multiline option enabled. Any ideas?

+3
2

:

@"^\d+;#([^/]+(?:/[^/]+)*?)(?:/\d+_\.\d+)?$"

, .

@"^\d+;#([^/]+(?:/(?!\d+_\.\d+$)[^/]+)*)"

, .

@"^\d+;#(.*?)(?:/\d+_\.\d+)?$"

, .

+3

^(\d+;#)([^/]+(/[^\d][^/]*)*)

. 1;#; URL- (, , /), /, , - , /.

, , , . .

0

Source: https://habr.com/ru/post/1717667/


All Articles