using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"OTHER REFERENCE:\s\d{8}\D{4}\s(?!\b(SHOPIFY)\b)\w+";
string input = @"OTHER REFERENCE: 20180201AIEJ SHOPIFY INTERNATIO SHOPIFY PMT AMT GBP 664367.38 |
OTHER REFERENCE: 20180201AJJS Shopify (Ireland) Limited SEPA Credit PMT AMT EUR 22718.08 |
OTHER REFERENCE: 20180301AIOV SHOPIFY INTERNATIO PMT AMT GBP 692673.45 |
OTHER REFERENCE: 20180302AKIH Shopify (Ireland) Limited SEPA Credit PMT AMT EUR 20147.37 |
OTHER REFERENCE: 20180226AJYS STRIPE DDA BACS PMT AMT GBP 122328.84 |
OTHER REFERENCE: 20180125AJDH STRIPE DDA BACS PMT AMT GBP 48392.41 |
OTHER REFERENCE: 20180103AGEJ STRIPE DDA BACS PMT AMT GBP 106257.89 | OTHER REFERENCE: 20180327AIQU STRIPE DDA BACS PMT AMT GBP 83725.34 |
(?m)^(?:(?!\bSHOPIFY\b).)+$";
foreach (Match m in Regex.Matches(input, pattern))
{
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