Have a query regarding Regular expressions...
Java
int PARSE_AUTHORITY_PORT = 3;
String input = "2089 krameria st., denver, co";
String expression = "/([0-9]+) ([^,]+), ([^,]+), (.+)/";
Perl5Util authorityMatcher = new Perl5Util();
if (authorityMatcher.match(expression, input))
{
String port = authorityMatcher.group(PARSE_AUTHORITY_PORT);
}
gives denver as output
where as in C#
String input = "2089 krameria st., denver, co";
String expression = "/([0-9]+) ([^,]+), ([^,]+), (.+)/";
Regex reg = new System.Text.RegularExpressions.Regex(expression, RegexOptions.IgnoreCase);
Match match = reg.Match(input);
if (match.Success)
{
GroupCollection grpc = match.Groups;
string port=match.Groups[3].ToString());
}
doesnt give me the desired out put if i try "([0-9]+) ([^,]+), ([^,]+), (.+)" instead of
"/([0-9]+) ([^,]+), ([^,]+), (.+)/" it gives me the same result. but my source files have lot of expressions and it's diffcult to go and check everwhere where exactly it fails.... Can nybdy helps me out .