I'm looking for help with using Regex to pull certain data from a string. I'm new to Regex and still relatively new to coding. I have looked for other questions but can't find any where the initial string might have more than one piece of data like mine.
In the below, I'm looking to extract the document number and assign to the "docNumber" string.
Case will always be 10 digits long. Customer may be 4 or 5 digits long. Document will always by 7 digits long.
The issue is that my Regex expression is just capturing the first 7 digits of the Case number.
static void Main(string[] args)
{
String testText = "Case 1628855986 Customer 7739 Document 9153862";
String docNumber = Regex.Match(testText, @"\d{7}").Value;
Console.WriteLine("The reference you are looking for is: " + docNumber);
}
Any help would be greatly appreciated!