I’m checking for valid user input for an executable; however it does include things like del/rm, dir/ls. The input is collected through XML and is validated using XSD. I will not check for file existence, since my program submits to a server, which may or may not have access to the same files.
The only requirements then, are that it not have a new line \r or \n and it cannot be entirely white space. I think it would be valid to assume that tab \t would not be allowed either, but I am more concerned with newlines.
Thanks
Does this mean you have the limitations mentioned here:
http://www.regular-expressions.info/xml.html
If so, then you probably want something like this:
[^\r\n\t]*[^\r\n\t\s][^\r\n\t]*The middle part means there has to be one character that is not a newline, tab, or whitespace. The rest of it means zero or more characters around that character that aren’t a newline or tab (but it can be whitespace). I think you might be able to remove the
\r\n\tfrom the middle group because they all might be encompassed in\sbut I haven’t tested any of this.Remove the three occurrences of
\tif you want tabs.