I am currently trying to find opening parentheses in a string using a regular expression in Elm 0.16 and replace each one with a bracket followed by one place. I also plan to replace each of the closing parentheses in the string with a space followed by a closing bracket. Therefore, I can replace the spaces with a comma to separate the line. The line I'm trying to use regex on is here:
((data "quoted data" 123 4.5) (data (! @ # (4.5) "(more" data "))))
I already used regex to remove any backslashes used to exclude quotes. For this, I used this function:
getRidOfBackslashes : String -> String getRidOfBackslashes sExpression = sExpression |> Regex.replace Regex.All (Regex.regex "\\g") (\_ -> "")
Then I tried to use the following function to achieve the previously stated goal regarding opening parentheses:
createSpacesParentheses sExpression = sExpression |> (\_ -> getRidOfBackslashes sExpression) |> Regex.replace Regex.All (Regex.regex "\(") (\_ -> "( ")
Looking at different jayscript controllers, my very simple regex seems to do what I want, but the Elm compiler gives me an error:
(line 1, column 3): unexpected "(" expecting space, "&" or escape code 27│ |> Regex.replace Regex.All (Regex.regex "\(") (\_ -> "( ") ^ Maybe <http:
I am wondering if I will do it right, and if someone can offer help. Thank you in advance.
source share