Hey guys, anyone know a way match a portion of a string with a regex expression?
attributes.modelId is of string type and is a string:
let length = String.length(attributes.modelId);
let lastIndex = String.rindex(attributes.modelId, ':');
let newModelId = String.sub(attributes.modelId, lastIndex + 1, length - (lastIndex + 1)) |> int_of_string
I was also thinking of doing:
attributes.modelId |> Js.String.match([%re "/\d+/"]) |> result => Js.log(result[0])
but trying to do result[0] gives me:
This has type:
option(array(Js.String.t))
But somewhere wanted:
array('a)
Any tips?