Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are in luck because C# is one of the few languages (if not the only one) that supports subexpression captures </p> <p><a href="https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.capture(v=vs.110)" rel="nofollow noreferrer">https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.capture(v=vs.110)</a></p> <p>The .NET API can be looked at as follows</p> <pre><code> Matches Groups (most regex engines stop here) Captures (unique for .NET) </code></pre> <p>It's not clear from your question what you want to match exactly but this should get you started. Ask again if you are stuck.</p> <pre><code> string input = "-group1 -group2 "; string pattern = @"(-\S*\W){2}"; foreach (Match match in Regex.Matches(input, pattern)) { Console.WriteLine("Match: {0}", match.Value); for (int groupCtr = 0; groupCtr &lt; match.Groups.Count; groupCtr++) { Group group = match.Groups[groupCtr]; Console.WriteLine(" Group {0}: {1}", groupCtr, group.Value); for (int captureCtr = 0; captureCtr &lt; group.Captures.Count; captureCtr++) Console.WriteLine(" Capture {0}: {1}", captureCtr, group.Captures[captureCtr].Value); } } </code></pre> <p>This ouputs</p> <pre><code>Match: -group1 -group2 Group 0: -group1 -group2 Capture 0: -group1 -group2 Group 1: -group2 Capture 0: -group1 Capture 1: -group2 </code></pre> <p>As you can see (Group 1, Capture 0) and (Group 1, Capture 1) offer the individual captures of a group (and not the last as in most languages)</p> <p>This address I think of what you describe as "to be able to backreference each of the values separately"</p> <p>(You use the term backreference but I don't think you are aiming for a replacement pattern right?)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload