View Problem

Check if a string matches with groups

Display "two" if "one two three" matches /one (.*) three/
DiskEdit
perl
print $1 if "one two three"=~/^one (.*) three$/
ExpandDiskEdit
java
Pattern pattern = Pattern.compile("one (.*) three");
Matcher matcher = pattern.matcher("one two three");
if (matcher.matches()) {
System.out.println(matcher.group(1));
}
DiskEdit
clojure
(if-let [groups (re-matches #"one (.*) three" "one two three")]
(println (second groups)))
ExpandDiskEdit
fantom
m := Regex<|one (.*) three|>.matcher("one two three")
if (m.matches)
echo("${m.group(1)}")

Submit a new solution for perl, java, clojure, or fantom
There are 15 other solutions in additional languages (cpp, csharp, erlang, fsharp ...)