View Problem

Check if a string matches with groups

Display "two" if "one two three" matches /one (.*) three/
DiskEdit
python
match = re.match(r'one (.*) three', 'one two three')
if match:
print match.group(1)
DiskEdit
csharp
using System;
using System.Text.RegularExpressions;

public class RegexBackReference {
public static void Main() {
var oneTwoThree = "one two three";
var pattern = "one (.*) three";

Match match = Regex.Match(oneTwoThree, pattern);

// group 0 is the entire match. 1 is the first backreference
Console.WriteLine(match.Groups[1]);
}
}
ExpandDiskEdit
fantom
m := Regex<|one (.*) three|>.matcher("one two three")
if (m.matches)
echo("${m.group(1)}")

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