rudorathod
IS-IT--Management
could someone give me the snippet where i can check if the first character in a string is a alphabet or not?
Thanks
Thanks
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
if ($SERIAL_NO =~ /^[a-z][^a-z]/i) {
# matches "A123" "AA123" "AAA123"
# YES NO NO
} elsif ($SERIAL_NO =~ /^[a-z]{2}[^a-z]/i) {
# matches "A123" "AA123" "AAA123"
# NO YES NO
} elsif ($SERIAL_NO =~ /^[a-z]{3}[^a-z]/i) {
# matches "A123" "AA123" "AAA123"
# NO NO YES
} elsif ($SERIAL_NO =~ /^[a-z]/i) {
# matches "A123" "AA123" "AAA123" "AAAAAAAAAA123"
# YES YES YES YES
}
I already did it,
if (substr("A123",0,1)==(/^[A-Z]/)) { print "match\n" }
# above prints "match"
if (substr("1A123",0,1)==(/^[A-Z]/)) { print "match\n" }
# above prints nothing.
if ('#' == (/^[a-zA-Z]/)) {
print "They are equal";
}
if (0 == ($_ =~ /^[a-zA-Z]/)) {
print "They are equal";
}
if (substr("1A123",0,1)==(/^[A-Z]/)) { print "match\n" }
if (1 == 0) {}