_modify

trait _modify
class java.lang.Object
trait scala.Matchable
class Any

Def

@targetName("joinTag")
inline def ++(v: A)(using d: Any.Def.Tag[A]): String

Join tag

Join tag

Joins value tag to base string.

Use it instead of '+'. Single plus joins '.toString' instead of '.tag', which often does not make sense especially for 'opaque values'

Note. This method should logically be called '+'. However, it is already defined in 'final class String' and cannot be overridden.

  val p = 12.Percent

  val s = "Value: " ++ p

  // same result as

  val s = "Value: " + p.tag
Source
_modify.scala
@targetName("joinOpt")
inline def +?(v: Opt[A])(using d: Any.Def.Tag[A]): String

Optional join

Optional join

Joins option value to base string.

Returns String "as is" for empty option.

Source
_modify.scala
inline def insertAt(i: Int, v: String): String

Insert at position

Insert at position

Creates new String with x inserted at the specified position

"0123456789".insertAt(5,"abc").tp // Prints: 01234abc56789
Source
_modify.scala
inline def label: String

Capitalize

Capitalize

Capitalizes first character of every word (separated by white spaces)

"all string ops".label.tp // Prints: All String Ops
Source
_modify.scala
inline def lower: String

toLowerCase

toLowerCase

Creates new String with all upper case Chars changed to lower case

"ABc".lower.tp // Prints: abc
Source
_modify.scala
inline def padEndTo(size: Int, pad: String): String

Pad end

Pad end

  Pads end of string to `targetLength`
Value Params
pad

string to pad with. "ABC".padEndTo(10,"_").tp // Prints: ABC_______

Source
_modify.scala
inline def padStartTo(size: Int, pad: String): String

Pad start

Pad start

  Pads start of string to `targetLength`
Value Params
pad

string to pad with. "ABC".padStartTo(10,"_").tp // Prints: _______ABC

Source
_modify.scala
inline def remove(v: String): String

Remove all

Remove all

Creates new String with all occurrences of x removed

"123123123123".remove("2").tp // Prints: 13131313
Source
_modify.scala
inline def replace(r: Int.Range, v: String): String

Replace range with x

Replace range with x

Creates new String with all occurrences of x replaced with target

"0123456789".replace(3 <> 7 ,"_").tp // Prints: 012_89
Source
_modify.scala
inline def replace(v: String, target: String): String

Replace all

Replace all

Creates new String with all occurrences of x replaced with target

"123123123123".replace("2","_").tp // Prints: 1_31_31_31_3
Source
_modify.scala
inline def replaceFirst(v: String, v2: String, cnt: Int): String
inline def replaceLast(v: String, v2: String, cnt: Int): String
inline def trim: String

Trim both ends

Trim both ends

Trims both ends of String from space Chars

Source
_modify.scala
inline def trimBoth(f: Char => Boolean): String

Trim both ends

Trim both ends

Trims both ends of String from Chars defined by let function

   "yyxxxxABCxxyyxx".trimBoth(_ in 'x' <> 'z') tp           // Prints: ABC

   "yyxxxxABCxxyyxx".trimBoth(c => c == 'x' || c == 'y').tp // Prints: ABC
Source
_modify.scala
inline def trimEnd: String

Trim end

Trim end

Trims end of String from space Chars

Source
_modify.scala
inline def trimEnd(f: Char => Boolean): String

Trim end

Trim end

Trims end of String from Chars defined by let function

   "ABCxxyyxx".trimEnd(_ in 'x' <> 'z') tp           // Prints: ABC

   "ABCxxyyxx".trimEnd(c => c == 'x' || c == 'y').tp // Prints: ABC
Source
_modify.scala
inline def trimStart: String

Trim start

Trim start

Trims start of String from space Chars

Source
_modify.scala
inline def trimStart(f: Char => Boolean): String

Trim start

Trim start

Trims start of String from Chars defined by let function

   "yyxxxxABC".trimStart(_ in 'x' <> 'z') tp           // Prints: ABC

   "yyxxxxABC".trimStart(c => c == 'x' || c == 'y').tp // Prints: ABC
Source
_modify.scala
inline def upper: String

toUpperCase

toUpperCase

Creates new String with all lower case Chars changed to upper case

"aBc".upper.tp // Prints: ABC
Source
_modify.scala