An implicit conversion that handles creating a Boolean from a string value.
An implicit conversion that handles creating a Boolean from a string value. This implicit definition, when in scope, allows code like the following:
val flag: Boolean = "true" // implicitly converts "true" to `true`
This method currently understands the following strings (in any mixture of upper and lower case). It is currently English-specific.
true, t, yes, y, 1 false, f, no, n, 0
the string to convert
a boolean value
if s cannot be parsed
Tokenize a string the way a command line shell would, honoring quoted strings and embedded escaped quotes.
Tokenize a string the way a command line shell would, honoring quoted strings and embedded escaped quotes. Single quoted strings must start and end with single quotes. Double quoted strings must start and end with double quotes. Within quoted strings, the quotes themselves may be backslash-escaped. Quoted and non-quoted tokens may be mixed in the string; quotes are stripped.
Examples:
val s = """one two "three four" "" for (t <- tokenizeWithQuotes(s)) println("|" + t + "|") // Prints: // |one| // |two| // |three four| val s = """one two 'three "four'""" for (t <- tokenizeWithQuotes(s)) println("|" + t + "|") // Prints: // |one| // |two| // |three "four| val s = """one two 'three \'four ' fiv"e""" for (t <- tokenizeWithQuotes(s)) println("|" + t + "|") // Prints: // |one| // |two| // |three 'four | // |fiv"e|
the string to tokenize
the tokens, as a list of strings
Useful string-related utility functions.