In PHP if we need to match a something like, ["one","two","three"]
, we could use the following regular expression with preg_match
.
$pattern = "/\[\"(\w+)\",\"(\w+)\",\"(\w+)\"\]/"
By using the parenthesis we are also able to extract the words one, two and three. I am aware of the Matcher
object in Java, but am unable to get similar functionality; I am only able to extract the entire string. How would I go about mimicking the preg_match
behaviour in Java.