Hi Jonathan, Thank you very much for your reply. I check your script, it did not work: for example: Suppose I give the string "abc", "abc123" "123" "abc_123" "abc.123": The string "abc", "abc123", "123", "abc-123" should be legal, but the "abc.123" should be NOT legal. I am using perl script to open user account, and check if user ID are legal or not. I just allow user ID include letters, numbers and underscore(_), excluding all other characters such as: !@#$%^&*(): all these stuff. But use script: if ($str =~ /[A-Za-z0-9\_]+/) { print "legal"; } else {print "Illegal";} It will print "Legal" with all the strings "abc" "abc123" "123" "abc_123" "abc.123" Thanks again. Grace Jonathan Daugherty <[EMAIL PROTECTED]> wrote:# Hello, I want to input a string which is used to create file name on unix. and I want to allow input string to consist of letters(A-Z, or a-z) and numbers(0-9) and underscroe( _ ) within file name. # # Does anoybody know how to check the input string legal or not?
# note: the following does not permit empty names. if ($input =~ /[A-Za-z0-9\_]+/) { # create file } else { # report error } -- Jonathan Daugherty http://www.cprogrammer.org --------------------------------- Do you Yahoo!? HotJobs - Search new jobs daily now