user1213444
user1213444

Reputation: 21

Pattern matching for string

I need a help for pattern for float value.

String that i have:

[[-307.,16.01,-171.31],[0.84528,-0.503623,-0.142485,-0.107531],[-1,-2,1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]], [[-306.43,24.47,-176],[0.845282,-0.503624,-0.142472,-0.107528],[-1,-2,1,1],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]]

Pattern that I'm using:

\s*[-+]?([0-9]*\.)?[0-9]*([eE][-+]?[0-9]+)?\s*

What changes that I have to do in my pattern such that I'm able to recognise whole text. Right now problem with
[306.43,24.47,-176] this which is part of this long string.
what changes I have to do with this pattern.

Upvotes: 0

Views: 145

Answers (2)

L.B
L.B

Reputation: 116178

No need for regex. You can use JavaScriptSerializer

var list = new JavaScriptSerializer()
                .Deserialize<List<List<List<Double>>>>("[" + yourstr + "]");

Upvotes: 2

Alberto
Alberto

Reputation: 525

It seems you are missing a + or * for the decimal places:

\s*[-+]?([0-9].)?[0-9]+([eE][-+]?[0-9]+)?\s*

Upvotes: 0

Related Questions