I'm trying to match positive开发者_JAVA技巧 and negative numbers inbetween two tags using regex, the positive numbers return fine but the negative ones do not match. I am using:
string value8 = (",\"lng\":\"(([^\"\\\\]|-\\\\.)*)\",");
Match[] lng = Regex.Matches(Text, value8)
to match against
"lng":"-104.845275878905880"
or similar, it can be positive or negative. When positive it matches the number but when negative, there are no matches.
Unless I'm missing something, your regex looks a little more complex than it needs to be. You should be able to use something like this:
"\"lng\":\\\"(-?[0-9]*\\.?[0-9]*)\\\""
Incidentally, I removed the comma at the beginning of your expression, as that would prevent this pattern from matching your sample data.
精彩评论