View Problem
Check if a string matches with groups
Display
Submit a new solution for ruby, cpp, fantom, clojure ...
There are 11 other solutions in additional languages (erlang, groovy, haskell, java ...)
"two" if "one two three" matches /one (.*) three/
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]);
}
}
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]);
}
}
Submit a new solution for ruby, cpp, fantom, clojure ...
There are 11 other solutions in additional languages (erlang, groovy, haskell, java ...)




