using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^pin ""([^""]*)"".* #.*@(\d+\.\d+\.\d+(?:[^\s]*)).*$";
string input = @"# Pin npm packages by running ./bin/importmap
pin ""application"", preload: true
pin ""@hotwired/turbo-rails"", to: ""turbo.min.js"", preload: true
pin ""@hotwired/stimulus"", to: ""https://ga.jspm.io/npm:@hotwired/stimulus@3.0.1/dist/stimulus.js""
pin ""@hotwired/stimulus-loading"", to: ""stimulus-loading.js"", preload: true
pin_all_from ""app/javascript/controllers"", under: ""controllers""
pin ""react"", to: ""https://ga.jspm.io/npm:react@16.0.0/index.js""
pin ""object-assign"" # @4.1.1
pin ""glob-parent"", to: ""https://ga.jspm.io/npm:glob-parent@3.1.0/index.js""
pin ""is-extglob"", to: ""https://ga.jspm.io/npm:is-extglob@2.1.1/index.js""
pin ""is-glob"", to: ""https://ga.jspm.io/npm:is-glob@3.1.0/index.js""
pin ""os"", to: ""https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.18/nodelibs/browser/os.js""
pin ""path"", to: ""https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/path.js""
pin ""path-dirname"", to: ""https://ga.jspm.io/npm:path-dirname@1.0.2/index.js""
pin ""process"", to: ""https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/process-production.js""
pin ""util"", to: ""https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.2/nodelibs/browser/util.js""
pin ""assastimulus"", to: ""https://ga.jspm.io/npm:stimulus@2.0.0/dist/stimulus.umd.js""
pin ""stimulus"", to: ""https://ga.jspm.io/npm:stimulus@2.0.0/dist/stimulus.umd.js""
pin ""lodash"" # @4.17.1 a comment
pin ""@github/hotkey"", to: ""@github--hotkey.js"" # @2.0.0
pin ""is-svg"", to: ""https://ga.jspm.io/npm:is-svg@3.0.0/index.js""
pin ""buffer"", to: ""https://ga.jspm.io/npm:@jspm/core@2.0.0-beta.19/nodelibs/browser/buffer.js""
pin ""html-comment-regex"", to: ""https://ga.jspm.io/npm:html-comment-regex@1.1.2/index.js""
pin ""nth-check"", to: ""https://ga.jspm.io/npm:nth-check@1.0.0/index.js""
pin ""boolbase"", to: ""https://ga.jspm.io/npm:boolbase@1.0.0/index.js""
pin ""jquery"", to: ""https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.js""
pin ""angularjs"", to: ""https://unpkg.com/angularjs@0.0.1/index.js""
pin ""angular"", to: ""https://unpkg.com/angular@1.8.2/index.js""
pin ""@angular/cli"", to: ""https://unpkg.com/@angular/cli@13.2.5/lib/cli/index.js""
pin ""underscore"" # a comment @1.13.2
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx