Created
March 16, 2012 13:06
-
-
Save notyy/2050000 to your computer and use it in GitHub Desktop.
how to improve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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