Skip to content

Instantly share code, notes, and snippets.

@MostafaGad1911
Created November 20, 2022 17:38
Show Gist options
  • Save MostafaGad1911/cf6a6702aae660ca799defd4a468824f to your computer and use it in GitHub Desktop.
Save MostafaGad1911/cf6a6702aae660ca799defd4a468824f to your computer and use it in GitHub Desktop.
val log_dump =
"name=Dan B, username=db, email=db@gmail.com, id=123; name=Hannah, username=hsmith, id=333, email=hsm@test.com; name=Dan Brick, username=db, email=db@gmail.com, id=663;"
val toTypedArray = log_dump.split(";").toTypedArray().filter { it.isNotEmpty() }
val filtered:ArrayList<String> = ArrayList()
for (item in toTypedArray) {
item.replace("${item.substringBefore(", id=").substringBefore(",")}", "")
Log.i("GadTest1", "$item")
}
toTypedArray?.forEachIndexed { index, data ->
if (index > 0){
if (!filtered.contains(data.substringAfter("username=").substringBefore(";")))
filtered.add(data)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment