jaipur07
asked on
Checking for a Character in String
I have file names in a folder like:
00001.tif, 00002.tif, MS001.tif, AX002.tif etc
I am reading files names using File API...what I want is I want to check if there is any alphabet in file name...
is there any straight forward method on String or String buffer to check that.
00001.tif, 00002.tif, MS001.tif, AX002.tif etc
I am reading files names using File API...what I want is I want to check if there is any alphabet in file name...
is there any straight forward method on String or String buffer to check that.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Given no numbers in the extension, you could do
boolean valid = fileName.matches("\\d+\\.\ \D+");
boolean valid = fileName.matches("\\d+\\.\
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> if there is any alphabet in file name
if (Pattern.matches("[^.]*[A- Za-z].*", filename))
if (Pattern.matches("[^.]*[A-
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
boolean valid = fileName.matches("[\\d.]+\ \w+");
What's the reason, GranMod?
is there=if there