using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<=a\/c|acc|account|ref|reference)\b\D+[0-9A-Za-z\-\\\/]+";
string input = @"My acc reference is 123456
My reference number is 123-456
My a/c reference number is 123-4556A
A/c number is 123-3456
This is another ref. number: 123/567-2B
cat and kitten both refer to cats.
He made reference in his novel to the 1929 census.
This data uses information from the financial year 1992/93 and also makes references to 90/91 figures.
The background property refers to a hexidecimal colour, H102567.
My a/c reference number is 123/456";
RegexOptions options = RegexOptions.IgnoreCase | 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