Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's not really a simple answer, but have you maybe though about using a regular expression for parsing the information out?</p> <p>Regular expressions is kinda hardcore stuff, but they can parsed advanced files quite easily.</p> <p>So in what I can see, then its like:</p> <blockquote> <p>If a line starts with A-Z, then (a-z or A-Z or 0-9 or space) from zero to many times, then followed by a : then a space, and then the value.</p> </blockquote> <p>So if you make a regular expression for that (If you wait awhile I will try to make one for you), then you could test each line with that. If it matches, then we can also use regular expressions to take the last part out, and the "key". If it don't matches, then we just append it to the last key.</p> <p>Beware that its not totally fool-proof, as a new line could just start this way, but its kinda the best thing we can do, i think.</p> <p><strong>As promised here is a starting point for your regular expression:</strong></p> <p><code>^(?'key'[A-Z][a-z,A-Z,0-9,\s]+):\s(?'value'.+)</code></p> <p>So to try and tell what it does, we need to go though each part:</p> <ul> <li><strong>^</strong> ensures that a match starts on the beginning of a line</li> <li><strong>(?'key'</strong> is a syntax to begin a "capture" group. The regular expression will then give us access to easily take the "key" part of the regular expression out.</li> <li>We that with a <strong>[A-Z]</strong> - that is a group that will match any big letter. But only one</li> <li><strong>[a-z,A-Z,0-9,\s]+</strong> - is like the previous group, but just for all big, or small letters, numbers and space (\s), the plus outside the group tells that it can match more than one.</li> <li>Then we just end the group, and puts in out *<em>:</em> and then a space.</li> <li>We then begin a new group the <strong>value</strong> group, just like the key group.</li> <li>Then we just write <strong>.</strong> (that means everything), and then just a <strong>+</strong> after that to make it catch more than one</li> </ul> <p>I actually think that you can just take the whole string, and just match a:</p> <p>RegEx.Matches (or something like that), and loop over them.</p> <p>Then just take match.Groups["key"] and match.Groups["value"] and put into your array. (Sorry i dont have a Visual Studio handy to test it out) </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload