I'm trying to match this recurring pattern in a json file:
{
"date":1568381400,
"open":301.7799987792969,
"high":302.1700134277344,
"low":300.67999267578125,
"close":301.0899963378906,
"volume":61426700,
"adjclose":301.0899963378906
}
Note: The above is the formatted version. The actual json is all one line (optional whitespace removed).
There are a bunch of them separated by commas, no spaces. I use the following code:
while ( $Page =~ /{"date":(.+?),.+?"high":(.+?),"low":(.+?),"close":(.+?),"volume":(.+?),.+?"adjclose":(.+?)}/g )
The regex returns TWO examples of the pattern for each such call. eg $& returns:
at84: matched:{"date":1623182400,"open":91.48999786376953,"high":92.379997253417
97,"low":90.77999877929688,"close":92,"volume":15404,"adjclose":92},{"date":1623072600,"open":89.80999755859375,"high":91.3499984741211,"low":89.80999755859375,"close":90.75,"volume":36200,"adjclose":90.75}
It never matches more nor less than precisely 2 of the patterns.
I've tried adding a '?' at the end of the pattern, which does nothing.
I suppose I could change the loop to index the commas or the {} block, but that would add a layer of kludge I'd like to avoid.
Has anyone any suggestions?
datein your sample input? Any other errors?