I am using regexp to ensure the string is all lower case,but it seems not useful.
Here’s my code
set name aAaaaA
if { [regexp {/^[a-z]$g} $name] } {
puts "continue"
} else {
puts "String is not lowercase. Please enter again"
}
I need to ensure the input is all lowercase ,and without any uppercase,symbol
And I’ve found [regexp (?=.*[\L]) $name] can express characters other than lowercase letters,but it’s not useful,too.
Can anyone help for this? Thanks!
>Solution :
You can use
set name aAaaaA
if { [regexp {^[[:lower:]]+$} $name] } {
puts "continue"
} else {
puts "String is not lowercase. Please enter again"
}
See the Tcl demo.
If an empty string is valid, replace + with *.
More details:
^– start of string[[:lower:]]+– one or more lowercase letters$– end of string.