Skip to content

Instantly share code, notes, and snippets.

@raanaYavari
Created February 19, 2022 19:11
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 raanaYavari/3e52e71b6e459d4859a39fcb16234b3f to your computer and use it in GitHub Desktop.
Save raanaYavari/3e52e71b6e459d4859a39fcb16234b3f to your computer and use it in GitHub Desktop.
fun findPartners(key: String, arr: Array<String>): Unit {
var name = key.substring(0, key.lastIndexOf('_'))
val regex = Regex(name + "_[0-9]+")
arr.forEach { s ->
if (regex.containsMatchIn(s)) {
println(s)
}
}
}
fun main(args: Array<String>) {
val s1 =
"/storage/emulated/0/DCIM/MomentRecorder/Videos/MomentRecorder_2022_02_19_10_20_331_1.mp4"
val s2 =
"/storage/emulated/0/DCIM/MomentRecorder/Videos/MomentRecorder_2022_02_19_10_20_331_2.mp4"
val s3 =
"/storage/emulated/0/DCIM/MomentRecorder/Videos/MomentRecorder_2022_02_19_10_20_331_3.mp4"
val s4 =
"/storage/emulated/0/DCIM/MomentRecorder/Videos/MomentRecorder_2022_02_19_10_20_332_4.mp4"
findPartners(s1, arrayOf(s1, s2, s3, s4))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment