Library
Module
Module type
Parameter
Class
Class type
Case related operations
Converts every character of a string to uppercase using the US-ASCII character set.
Rosa.Case.uppercase "rosa";;
- : string = "ROSA"
Converts every character of a string to lowercase using the US-ASCII character set.
Rosa.Case.lowercase "ROSA";;
- : string = "rosa"
Converts only the first character of the string to uppercase, using the US-ASCII character set. If p is not explicitly set to 1, then remaining characters of the string will be converted to lowercase as well.
Rosa.Case.capitalize "roSa case";;
- : string = "Rosa case"
Rosa.Case.capitalize ~p:1 "roSa case";;
- : string = "RoSa case"
Same as capitalize
but requires the index of the character to be capitalized. Does not alter remaining characters in any way. Raises failure if the give index is out of bounds.
Rosa.Case.cap_at 2 "rosa";;
- : string = "roSa"
Same as cap_at_exn
but does not raises any exception
Rosa.Case.cap_at 4 "rosa";;
- : string = "rosa"
Rosa.Case.cap_at_exn 4 "rosa";;
Exception:
Failure "Rosa.Case.cap_at_exn : index 4 is out of bounds, it should lie in [0, 3]".
Similar to capitalize
Rosa.Case.uncapitalize "Rosa case";;
- : string = "rosa case"
Similar to cap_at_exn
Rosa.Case.uncap_at 2 "ROSA";;
- : string = "ROsA"
Converts the given string to camel case.
Rosa.Case.camel "rosa case camel";;
- : string = "rosaCaseCamel"
Swaps the case of alphabets in given string.
Rosa.Case.swap "Rosa Case Swap";;
- : string = "rOSA cASE sWAP"
Converts the given string to title case.
Rosa.Case.title "rosa case title";;
- : string = "Rosa Case Title"
Rosa.Case.title ~space:0 "rosa case title";;
- : string = "RosaCaseTitle"
Converts the given string to snake case.
Rosa.Case.snake "Rosa case snake";;
- : string = "rosa_case_snake"
Rosa.Case.snake "_Rosa case snake";;
- : string = "rosa_case_snake" // cleans underscores present at the beginning and the end
Rosa.Case.snake ~clean:0 "_Rosa case snake";;
- : string = "_Rosa_case_snake"