I have a program which takes a users details and saves them in a pdf.
The name of the pdf file should consist of the users id, an underscore
and the users surname, e.g. 01_Smith.pdf
Thing is, how do I check for illegal file name characters in the
On Windows for example, the characters /:*?"<>| are not allowed in a
file name, so obviously they shouldn’t occur in the surname.
As there seem to be multiple combinations of illegal file name
characters on different operating systems, I thought about stripping
everything except letters from the surname and came up with:
But as we have users from around the world, it is common for them to
have special characters in their surname (e.g. Ã¤Ã¶Ã¼ÃŸ in Germany). The
above reg exp strips these out too, which isn’t perfect.
Is there a reg exp which would strip out everything but letters and
leave special characters in tact or am I going about this the wrong
Any tips would be greatly appreciated.