Splitting a string with `Js.String.splitByRe`
In ReasonML you are not always in a JS context, but when you are, you can use
Js.String.splitByRe for splitting.
let regex = [%re "/\|/"]; let results = Js.String.splitByRe(regex, "Apple|Bird|Turtle"); Js.log(results);
You can play around with it here.
As a sidenote, if you read the docs on the Str module it looks like there are Reason ways to do this, but I can't get anything in that module to work.
In a ReasonML "Try" window here I try calling:
But just get the error
Pretty confusing :/.Tweet