Hello
Both posted scripts of mine do not care whether spaces are between tokens. So there's something else we're missing.
• The first thing to note is that both scripts I posted should filter out such paragraph as -
"Wood":"45","Water":"0","Stone":"1220","Fire":"9","Hammer":"355"
because it does not start with character {.
If you meant to say it doesn't filter out -
{"Wood":"45","Water":"0","Stone":"1220","Fire":"9","Hammer":"355"}
then the first script won't but the second will.
To make it clear, given the text -
"Wood":"45","Water":"0","Stone":"1220","Fire":"9","Hammer":"355"
{"Wood":"45","Water":"0","Stone":"1220","Fire":"9","Hammer":"355"}
"Wood":"45","Water":"1","Stone":"1220","Fire":"9","Hammer":"355"
{"Wood":"45","Water":"1","Stone":"1220","Fire":"9","Hammer":"355"}
result of the first script is -
{"Wood":"45","Water":"0","Stone":"1220","Fire":"9","Hammer":"355"}
result of the second script is -
{"Wood":"45","Water":"1","Stone":"1220","Fire":"9","Hammer":"355"}
Is the latter what you expect?
• Another thing to note is text encoding.
Is it really in UTF-8? If it is in UTF-16LE, the second script can still filter out paragraphs not starting with { but cannot filter out those with "Water":"0" because the pattern won't match in its current state.
To make clear that the input file is in UTF-8, you may resave it via TextEdit.app with its preferences set to save in UTF-8.
• Lastly, line ending.
It is assumed that LF (U+000A: LINE FEED) terminates paragraph. Not CR (U+000D: CARRIAGE RETURN).
If the scripts can filter out every paragraph not starting with {, then the current line ending should be fine.
That's all for now.
Good luck,
H