Ignoring white space for a Regex match

(\d *){8,}

It matches eight or more occurrences of a digit followed by zero or more spaces. Change it to

( *\d *){8,}  #there is a space before first asterik

to match strings with spaces in the beginning. Or

(\s*\d\s*){8,}

to match tabs and other white space characters (that includes newlines too).

Finally, make it a non-capturing group with ?:. Thus it becomes (?:\s*\d\s*){8,}

Leave a Comment