必须搜索子字符串是否存在于字符串中
我有几个子字符串要在下面的字符串中搜索
These are the substrings "School, Students, Teachers, Classrooms"
下面是这里的字符串我搜索上面的子字符串是否出现在下面的字符串中
School_Name
Number_Of_Students
Number_Of_Teachers
Number_Of_Classrooms
-我已经尝试过这种方式,在字符串中我有学生、教师、教室存在子字符串,但我无法正确搜索它
#!/usr/bin/tclsh
set list {School Students Teachers Classrooms}
set string "Number_Of_Students Number_Of_Teachers Number_Of_Classrooms"
if {"$string" in $list} {
puts "$string"
}
任何人都可以帮我吗
I have a few substrings to search in the below following strings
These are the substrings "School, Students, Teachers, Classrooms"
Below are the strings here I have the search whether the above substrings are present in the below strings-
School_Name
Number_Of_Students
Number_Of_Teachers
Number_Of_Classrooms
I have tried in this way, here in the string I have Students, Teachers, Classrooms substrings present, but I'm not able to search it properly
#!/usr/bin/tclsh
set list {School Students Teachers Classrooms}
set string "Number_Of_Students Number_Of_Teachers Number_Of_Classrooms"
if {"$string" in $list} {
puts "$string"
}
Can anyone help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
in
运算符only 执行字符串与列表元素的精确匹配。您可能希望将lsearch
与string match
样式的 glob 模式一起使用;他们很容易合作。或者也许只是字符串匹配
和一些foreach
循环;我不确定模式列表是什么以及搜索空间列表是什么。The
in
operator only does exact matching of a string against elements of a list. You probably want to uselsearch
with astring match
-style glob pattern; they're fairly easy to work with. Or maybe juststring match
and someforeach
loops; I'm not sure what are the list of patterns and what are the list that is the search space.