4

Hello I have a problem with parsing this text

{
    {
        {
            {[system1];1;1;0.612509325};
            {[system2];1;1;0.977659115};
            {[system3];1;1;36.97828732969};
            {[system4];1;1;61.43154423}
        };2.5469
    };
    {
        {
            {[system5];1;1;0.9613443};
            {[system6];1;1;2.06340392};
            {[system7];1;1;4.12680784};
            {[system8];1;1;6.18989626};
            {[system9];1;1;24.75958504758};
            {[system10];1;3;61.8989626189}
        };31.6952
    }
}

I need to parse it into an object like this

class Group
{
  Rate = 31.6952
  Systems = 
   {
    System5 = {[system5];1;1;0.9613443};
    System6 ={[system6];1;1;2.06340392};
    System7 ={[system7];1;1;4.12680784};
    System8 ={[system8];1;1;6.18989626};
    System9 ={[system9];1;1;24.75958504758};
    System10 ={[system10];1;3;61.8989626189}
   }
}

I tried

({[^{}]})

but it doesn't group it well.

Glock
  • 63
  • 4

1 Answers1

1

try this regex

{[\d\w]*.*?}

It will return

{[system5];1;1;0.9613443}

From

System5 = {[system5];1;1;0.9613443};
og Grand
  • 114
  • 3
  • Add data, that you want to grab from string – og Grand Dec 12 '12 at 14:04
  • I mean your regex is not working in the way it looks like it's intended to work. The whole match (excluding `{` and `}`) is actually performed by `.*`. The `[\d\w]*` will not match anything in this example. – El Ronnoco Dec 12 '12 at 15:26