shopt -s extglob
INPUT="Ad123"
case $INPUT in
( +([[:digit:]]) ) echo "$INPUT is all numbers" ;;
( +([[:alpha:]]) ) echo "$INPUT is all characters" ;;
( +([[:alnum:]]) ) echo "$INPUT is alphanumeric" ;;
( *) echo "$INPUT is empty or something unknown" ;;
esac
Hello,
what do you mean by this "I want to even block only single dot or multiple dots..
". this implies that you dont want dots at all?
the regex that you are trying is absolutely wrong.
In (character class) {}(counter) doesnt work. except it becomes a literal.
([^a-zA-Z]) implies that these alphabets are not included contrary to the one you have stated above. -> "want to block all special characters except alphanumerics.. "..
I want to allow alphanumeric characters and single dot in between the characters,multiple dots should not be allowed.
ex :
1 . (single) dot should not be allowed in the string
2. ...... (multiple dots should not be allowed in the string)
3. a.b.c (dots in b/w the characters can be allowed)
4. special characters other than alphanumeric characters should not be allowed
The following is the jquery code.
Here am reading the values entered in the text box and evaluating that string.
variable fName contains the original string here .
$("#fName").blur(function(){
var fName = jQuery.trim($("#fName").val()); // removing white spaces
var words = fName.split(/[^a-zA-Z0-9.]/); // allowing only alphanumerics and //.(dot character) here
nfName = jQuery.trim(words.join(" ")); // again joining the string
if(nfName != fName)
{
alert("Special characters other than \".\" are not allowed");
}
});
am able to block all special characters except .
but i want the following criteria to be passed.
ex :
1 . (single) dot should not be allowed in the string i.e (complete string should not be single dot)
2. ...... (multiple dots should not be allowed in the string) i.e (string should not be only dots)
3. a.b.c (dots in b/w the characters can be allowed)
4. special characters other than alphanumeric characters should not be allowed