Validating a file with regular expressions read i kissed dating goodbye online

Rated 3.98/5 based on 755 customer reviews

To match a particular email address with regex we need to utilize various tokens.The following regex snippet will match a commonly formatted email address.So, when created via the Mac machine, file path and file name can have special characters like * @ $ ?etc., but that gives trouble to my code running on Windows machine.If you’re using regex in a web project and would like a quick reference to the regex tokens available, use the regex cheatsheet above as well the tools mentioned to help simplify the regex expression building process. A regular expression, or regex for short, is a pattern describing a certain amount of text.For example, with regex you can easily check a user’s input for common misspellings of a particular word (e.g. This guide provides a regex cheatsheet that you can use as a reference when creating regex expressions.

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

So, I would like to write a piece of code that checks for the presence of special characters (pretty much everything other than a-z, A-Z, 0-9, _, -) in the file path or file name; and accordingly perform rest of the activities.

The part where I seek your help is writing the regex expression: Point to note: The file Path is the path of the file plus the file name and extension.

Example: \prod1\customer1\title1\my And it can be any level deeper, so I have to validate the whole path and the file name.

According to my understanding, below will be the code to perform the above: In explanation: "matches" is a method on String.

Leave a Reply