-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
safer starts_with function #97
Comments
I think there is even a possible problem in case ~prfx contains some regexp special characters. (* does the string starts with prefix ? *) |
I am in some other code using this same function, that's why |
On 11/6/2012 1:52 AM, Francois Berenger wrote:
let starts_width ~str ~prefix = if String.length str < String.length E. |
No, the matched substring must start at index 0 in the code I gave. The documentation of the Str module is not that crystal clear. |
It should be like this to be less error prone at use:
(* does the string starts with prefix ? *)
let starts_with ~str ~prfx =
Str.string_match (Str.regexp ("^" ^ prfx)) str 0
The text was updated successfully, but these errors were encountered: