package rosa

  1. Overview
  2. Docs

Module Rosa.CaseSource

Case related operations

Sourceval uppercase : string -> string

Converts every character of a string to uppercase using the US-ASCII character set.

  Rosa.Case.uppercase "rosa";;
  - : string = "ROSA"
Sourceval uc : string -> string

Same as uppercase

Sourceval lowercase : string -> string

Converts every character of a string to lowercase using the US-ASCII character set.

  Rosa.Case.lowercase "ROSA";;
  - : string = "rosa"
Sourceval lc : string -> string

Same as lowercase

Sourceval capitalize : ?p:int -> string -> string

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"
Sourceval cap : ?p:int -> string -> string

Same as capitalize

Sourceval cap_at_exn : int -> string -> string

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"
Sourceval cap_at : int -> string -> string

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]".
Sourceval uncapitalize : ?p:int -> string -> string

Similar to capitalize

  Rosa.Case.uncapitalize "Rosa case";;
  - : string = "rosa case"
Sourceval uncap : ?p:int -> string -> string

Same as uncapitalize

Sourceval uncap_at_exn : int -> string -> string

Similar to cap_at_exn

  Rosa.Case.uncap_at 2 "ROSA";;
  - : string = "ROsA"
Sourceval uncap_at : int -> string -> string

Similar to cap_at

Common case conventions

Sourceval camel : string -> string

Converts the given string to camel case.

  Rosa.Case.camel "rosa case camel";; 
  - : string = "rosaCaseCamel"
Sourceval camelCase : string -> string

Same as camel

Sourceval camelcase : string -> string

Same as camel

Sourceval swap : string -> string

Swaps the case of alphabets in given string.

  Rosa.Case.swap "Rosa Case Swap";;
  - : string = "rOSA cASE sWAP"
Sourceval swapcase : string -> string

Same as swap

Sourceval title : ?space:int -> string -> string

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"
Sourceval titlecase : ?space:int -> string -> string

Same as title

Sourceval snake : ?clean:int -> string -> string

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"
Sourceval snakecase : ?clean:int -> string -> string

Same as snake

Query

Sourceval is_lowercase : string -> bool
Sourceval is_lc : string -> bool

Same as is_lowercase

Sourceval is_uppercase : string -> bool
Sourceval is_uc : string -> bool

Same as is_uppercase

OCaml

Innovation. Community. Security.