implicit final class StringOps extends AnyVal
- Alphabetic
- By Inheritance
- StringOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new StringOps(s: 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
-
def
asBytes: Long
Converts the scala.Predef.String representation of memory (e.g.
Converts the scala.Predef.String representation of memory (e.g.
10mb,1.1kb, etc.) to a scala.Long representation of the number of bytes. It is forgiving of leading and trailing whitespace as well as whitespace between the numerical portion and the unit of memory.If the scala.Predef.String does not match any known representation of memory, the fallback is to attempt to convert the entire scala.Predef.String to a scala.Long
For consistency, rounding to scala.Long is used in both of the above cases.
Examples
scala> val foo = "1.5kb".asBytes foo: Long = 1536 // fall back using toLong scala> val foo = "1100b".asBytes foo: Long = 1100 scala> val foo = "1100".asBytes foo: Long = 1100 // rounding, would otherwise be 9341.952b scala> val foo = "9.123kb".asBytes foo: Long = 9342 // fallback rounding, for consistency scala> val foo = "9.1b".asBytes foo: Long = 9 scala> val foo = "9.1".asBytes foo: Long = 9
- Annotations
- @throws( classOf[NumberFormatException] )
- Version
0.3.0
- Exceptions thrown
java.lang.NumberFormatException- If the string does not contain a memory representation that is parsable to a scala.Long
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
toAlpha: String
removes all non-alpha characters from the scala.Predef.String (non-
[a-zA-Z])removes all non-alpha characters from the scala.Predef.String (non-
[a-zA-Z])Example
scala> val foo = "a1b2c3!@#".toAlpha foo: String = abc
- Version
0.3.0
-
def
toAlphanumeric: String
removes all non-alphanumeric characters from the scala.Predef.String (non-
[0-9a-zA-Z])removes all non-alphanumeric characters from the scala.Predef.String (non-
[0-9a-zA-Z])Example
scala> val foo = "a1b2c3!@#".toAlphanumeric foo: String = a1b2c3
- Version
0.3.0
-
def
toNumeric: String
removes all non-numeric characters from the scala.Predef.String (non-
[0-9])removes all non-numeric characters from the scala.Predef.String (non-
[0-9])Example
scala> val foo = "a1b2c3!@#".toNumeric foo: String = 123
- Version
0.3.0
-
def
toString(): String
- Definition Classes
- Any