I’m creating a program that grabs all names in a given document with the below regex.
string pattern = @"(?<=Name)[\s](.*?)[\s]";
However this regex will not work if the document has name in it but used in a different context. Hence I modified my code below.
string pattern @"(?<=Name:[\s])(.*?)[\s]";
However even though this regex works, it only runs once and outputs the first name it finds unlike the first regex shown
Edited ——— Document has a series of names like Name: John Name: Jane Name: Mary
There will be a sentences below but with the word name being used, what I want is just for the Words after Name: to be grabbed throughout the document.
What I used to trigger the output is:
If (MatchesPattern.success)
{
RegexWriter(pattern.value, fileName)
}