Validating a file with regular expressions

Therefore, with the above regex expression for finding phone numbers, it would identify a number in the format of 123-123-1234, 123.123.1234, or 1231231234.

In the case of including the "\" character in the regular expression, you will need to escape both of them, so you have "\\".

In the regex, "." is any character and "*" means "0 or more times".

So .*[ ].* would mean a space surrounded by any other characters Square brackets [] match any of the alternative characters within them ^ (as first character inside the square brackets) means "NOT these characters" \w means word-characters, i.e.

A-Za-z0-9 and _ Certain characters like [ and ] need to be escaped with a \ for more info see Wikipedia regular expressions Thanks so much Luigi for such detailed explanation. With the code snippet that you have given, I can perform the check on individual file name or folder name.

But I want to validate the whole file path, which contains '\' as file separator.

Leave a Reply

  1. Chat xxx onlin peekshow 03-Mar-2020 04:22

    While women from Hong Kong aren’t as shy as many other Asian counterpart, they’re not as aggressive as women from other countries. Pick Your Date Location Carefully Watch out for the location you choose for your date.

  2. dating one month 08-Mar-2020 13:00

    A group of high school students are under police investigation in Gyeongnam province for secretly filming three female teachers.