如何在TCL中找到大写和小写字母的计数

发布于 2025-01-26 05:27:08 字数 205 浏览 1 评论 0 原文

如何在TCL中找到大写AMD较低情况的计数 使用此代码,我只获得ASCII值

foreach character {H e l l o T C L} {
    scan $character %c numeric
    puts "ASCII character '$numeric' displays as '$character'."
}

how to find the count of uppercase amd lower case in tcl
with this code im getting only ascii values

foreach character {H e l l o T C L} {
    scan $character %c numeric
    puts "ASCII character '$numeric' displays as '$character'."
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜雨飘雪 2025-02-02 05:27:08

您可以使用 REGEXP 来为您提供计数:

set str "Hello Tcl"
puts "Uppercase: [regexp -all {[[:upper:]]} $str]"
puts "Lowercase: [regexp -all {[[:lower:]]} $str]"

我使用 [:upper:]] [[:::较低:]] 而不是 [az] [az] ,因为前者将正确捕获Unicode上下语,而不仅仅是仅仅捕获Unicode的上下文ASCII集。

Instead of looping through a string yourself, you can use regexp to give you a count:

set str "Hello Tcl"
puts "Uppercase: [regexp -all {[[:upper:]]} $str]"
puts "Lowercase: [regexp -all {[[:lower:]]} $str]"

I'm using [[:upper:]] and [[:lower:]] instead of [A-Z] and [a-z] because the former will correctly capture unicode upper- and lowercase, rather than just the ones in the ASCII set.

莫言歌 2025-02-02 05:27:08

您可以使用字符串为$ targe 字符串为较低$ tarnic 来测试每个字符。请注意,非字母字符既不是上层或下情况。有关更多信息,请访问 httpps:// wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww of

You can test each character with string is upper $character and string is lower $character. Note that non-alphabetic characters are neither upper or lower case. For more info check the documentation at https://www.tcl-lang.org/man/tcl8.6/TclCmd/string.htm#M10

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文