An API responds with a string such as the following.
"\"APPROVED\"|\"222222\"|\"11111111\"|\"\"|\"M\"|\"\"|\"5454\"|\"MC\""
I was using the following code to parse
str = str.scan(/\w+/)
This worked fine, as I could str[0], str[1], etc..
Than a response such as
"\"DECLINED\"|\"\"|\"64243178\"|\"\"|\"\"|\"\"|\"Invalid Exp Date\"|\"\"|\"5454\"|\"MC\""
Trying to parse Invalid Exp Date ends up with simply
str[2] => Invalid
I tried the following
str.split("\"|")
But there is always a quote in the beginning
"Invalid Exp Date
"APPROVED
What is the best way to parse such a string?
|as a delimiter)["APPROVED", "222222",..., "MC"], I assume.