Skip to content

Instantly share code, notes, and snippets.

@notyy
Created March 16, 2012 13:06
Show Gist options
  • Save notyy/2050000 to your computer and use it in GitHub Desktop.
Save notyy/2050000 to your computer and use it in GitHub Desktop.
how to improve
scala> val source ="access_token=C4F0730***********485824&expires_in=7776000"
source: java.lang.String = access_token=C4F0730***********485824&expires_in=7776000
scala> val (accToken, expire) = (source.split('&')(0).split('=')(1), source.split('&')(1).split('=')(1))
accToken: String = C4F0730***********485824
expire: String = 7776000
@lshoo
Copy link

lshoo commented Mar 17, 2012

scala> val sregex = """access_token=([^,]+)&expires_in=(.+)""".r
sregex: scala.util.matching.Regex = access_token=([^,]+)&expires_in=(.+)

scala> val sregex(token, expires) = source
token: String = C4F0730*********485824
expires: String = 7776000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment