Right now I am trying to remove any commas that are contained within quotation marks and replace them with spaces in this string:
(,(,data,"quoted,data",123,4.5,),(,data,(,!@#,(,4.5,),"(,more","data,)",),),)
I am currently using this function that uses Javascript style regex:
removeNeedlessCommmas sExpression =
sExpression
|> (\_ -> replaceSpacesWithCommas sExpression)
|> Regex.replace Regex.All (Regex.regex ",") (\_ -> ",(?!(?:[^"]*"[^"]*")*[^"]*$)g")
This regex is displayed as working correctly in sites such as regex101.com.
However, I have tried many ways of escaping the regex so that it works in Elm 0.16, but the rest of my code in my file is always still highlighted like the rest of the file is enclosed in a string. This is the error that I am getting with my current code:
(line 1, column 64): unexpected "_" expecting space, "&" or escape code
39│ printToBrowser "((data \"quoted data\" 123 4.5) (data (!@#(4.5) \"(more\" \"data)\")))"
Maybe <http://elm-lang.org/docs/syntax> can help you figure it out.
I will post the main function that the error is referring to so that it makes more sense:
main : Html.Html
main =
printToBrowser "((data \"quoted data\" 123 4.5) (data (!@# (4.5) \"(more\" \"data)\")))"
Any assistance would be greatly appreciated. Thanks in advance.