regex - Scala: How to always extract the same substring out from strings with different prefix and/or suffix -
given following strings...
val s0 = "objects" val s1 = "/objects" val s2 = "/objects(0)" val s3 = "/objects(1)"
i need extract substring objects
, regardless of possible prefix , suffix. if string started slash , ended (n)
, easiest solution be
scala> s3.substring(1).substring(0, s3.indexof("(") - 1) res1: string = objects
how extract string objects
regex (i suppose way go)?
Comments
Post a Comment