I have a regular expression. I want to check if it starts with ^ and if not, create a new regular expression with ^ at the beginning. Like this...
letpatternMustStart=pattern=> {
letoriginal=pattern->RegExp.sourceswitchoriginal->String.startsWith("^") {
| true=>pattern
| false=>RegExp.fromStringWithFlags("^"++original, ~flags=Js.Re.flags(pattern))
}The RegExp.flags function is missing. Must use Js.Re instead.
I have a regular expression. I want to check if it starts with ^ and if not, create a new regular expression with ^ at the beginning. Like this...
The
RegExp.flagsfunction is missing. Must useJs.Reinstead.