I need a regular expression that matches a word. However the expression must be valid until the word is completed.
Example: Using the word "stackoverflow"
all parts of words must be valid "s" "st" "sta" "stac" "stack" "stacko" .... so on until the complete word.
if there is "stt" is invalid.
Also have to consider that the words "stackoverflowx" or "xstackoverflow" are invalid
Thank you all.
This is a problem that sounds it would be much better solved with
var input = "st"; // or "sta", or ...
bool isValid = "stackoverflow".StartsWith(input);
Is there some reason you have to use a regular expression?