I am trying to write a java regular expression where my application should restrict the names of the files or filetypes mentioned in the regex from being attached to an email. I started the regex like this,
Is this correct?. Right now it is not working(matching). Not sure where I am going wrong. Also, how can I add new file types or filenames to this expression incase if I want to expand this regex. Like say, I want to add the vcf file types also here in this regex, how should I do that? Also, If I need to add the filenames, say abc.bmp from being attached, how and where should I include that filename in this regex?. Any help is greatly appreciated as I am new to this regex.
There's no need for Regex, and no need to reinvent a wheel that already exists. You can use javax.swing.filechooser.FileNameExtensionFilter and test the value returned from accept(...)
edit And if I'd seen that you don't bother to return to most of the threads you start, I wouldn't have bothered to respond to this one.
Edited by: Darryl Burke
Darryl , I can't use Swing in my application. So I need to use a regex. This regex will be in a configuration page in my application where the user(client) can modify it to notify the filetypes or file names that they want to ignore from processing. So once my application receives a file, it will get this regex and do a compare with the current file to check if it matches the pattern. If it matches, I should ignore the file. The current regex that I have is
Do you think if I am missing something here?. for some reason this doesn't work for me.
Darryl , I can't use Swing in my application.
Does this mean "I can't use GUI components" or "I can't use any classes in the javax.swing hierarchy"?
If it's the former (which would be the most reasonable interpretation in real life) then there's nothing stopping you from using javax.swing.filechooser.FileNameExtensionFilter.