G
Guest
Hi,
I want to parse string like "<number><trailing-char><title>" where <number>
is a string containing digits and dots, <trailing-char> a whitespace or a
semicolon and <title> any chars.
I use a regexp (framework 1.1) to parse the strings. Here is the code:
static Regex reNumSepTitle = new
Regex(@"^(?<number>[\d-\.]+)([:\s])+(?<title>.*)$");
public static string ExtractTitle(string str) {
string title = str.Trim();
m = reNumSepTitle.Match(title);
if ( m.Success ) {
return m.Result("${title}");
}
return title;
}
When I call the method with "1.1:\tHeading", it returns "Heading".
With "1.1.1.1:\tHeading", I get "\tHeading" (and the number part is '1.').
What's wrong ?
Thanks.
I want to parse string like "<number><trailing-char><title>" where <number>
is a string containing digits and dots, <trailing-char> a whitespace or a
semicolon and <title> any chars.
I use a regexp (framework 1.1) to parse the strings. Here is the code:
static Regex reNumSepTitle = new
Regex(@"^(?<number>[\d-\.]+)([:\s])+(?<title>.*)$");
public static string ExtractTitle(string str) {
string title = str.Trim();
m = reNumSepTitle.Match(title);
if ( m.Success ) {
return m.Result("${title}");
}
return title;
}
When I call the method with "1.1:\tHeading", it returns "Heading".
With "1.1.1.1:\tHeading", I get "\tHeading" (and the number part is '1.').
What's wrong ?
Thanks.