implicit final class RichString extends AnyVal
- Alphabetic
- By Inheritance
- RichString
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new RichString(string: String)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def getOrElse(default: => String): String
Return the string unless it is null or empty, in which case return the default.
Return the string unless it is null or empty, in which case return the default.
- default
the string to return if inputString is null or empty
- returns
either the inputString or the default
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def quoteC(): String
Quote a string so that unprintable chars (in ASCII) are represented by C-style backslash expressions.
Quote a string so that unprintable chars (in ASCII) are represented by C-style backslash expressions. For example, a raw linefeed will be translated into
"\n"
. Control codes (anything below 0x20) and unprintables (anything above 0x7E) are turned into either"\xHH"
or"\\uHHHH"
expressions, depending on their range. Embedded backslashes and double-quotes are also quoted.- returns
a quoted string, suitable for ASCII display
- def regexSub(re: Regex)(replace: (MatchData) => String): String
For every section of a string that matches a regular expression, call a function to determine a replacement (as in python's
re.sub
).For every section of a string that matches a regular expression, call a function to determine a replacement (as in python's
re.sub
). The function will be passed the Matcher object corresponding to the substring that matches the pattern, and that substring will be replaced by the function's result.For example, this call:
"ohio".regexSub("""h.""".r) { m => "n" }
will return the string
"ono"
.The matches are found using
Matcher.find()
and so will obey all the normal java rules (the matches will not overlap, etc).- re
the regex pattern to replace
- replace
a function that takes Regex.MatchData objects and returns a string to substitute
- returns
the resulting string with replacements made
- val string: String
- def toCamelCase: String
Converts foo_bar to fooBar (first letter lowercased)
Converts foo_bar to fooBar (first letter lowercased)
For example:
"hello_world".toCamelCase
will return the String
"helloWorld"
. - def toOption: Option[String]
Wrap the string in an Option, returning None when it is null or empty.
- def toPascalCase: String
Converts foo_bar to FooBar (first letter uppercased)
Converts foo_bar to FooBar (first letter uppercased)
For example:
"hello_world".toPascalCase
will return the String
"HelloWorld"
. - def toSnakeCase: String
Converts FooBar to foo_bar (all lowercase)
Converts FooBar to foo_bar (all lowercase)
For example:
"HelloWorld".toSnakeCase
will return the String
"hello_world"
. - def toString(): String
- Definition Classes
- Any
- def unhexlify(): Array[Byte]
Turn a string of hex digits into a byte array.
Turn a string of hex digits into a byte array. This does the exact opposite of
Array[Byte]#hexlify
. - def unquoteC(): String
Unquote an ASCII string that has been quoted in a style like
quoteC
and convert it into a standard unicode string.Unquote an ASCII string that has been quoted in a style like
quoteC
and convert it into a standard unicode string."\\uHHHH"
and"\xHH"
expressions are unpacked into unicode characters, as well as"\r"
,"\n"
,"\t"
,"\\"
, and'\"'
.- returns
an unquoted unicode string