Skip to content

Instantly share code, notes, and snippets.

@uburoiubu
Last active May 3, 2018 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uburoiubu/6ef31c56573a74fe4e4c5709936c1d06 to your computer and use it in GitHub Desktop.
Save uburoiubu/6ef31c56573a74fe4e4c5709936c1d06 to your computer and use it in GitHub Desktop.
@Test
fun extractPlaceholderData() {
val input = "{{product:12;k:13}}, {{product:14;k:15}}"
val regex = "\\{\\{.+:(.+);.+:(.+)}}".toRegex()
var result = regex.find(input)
result?.destructured?.let {
(first, second) -> println("$first : $second")
}
result = result?.next()
result?.destructured?.let {
(first, second) -> println("$first : $second")
}
}
// Output:
14 : 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment