用户输入字符串包含某些字符测试 [英] User-input string contains certain character test
问题描述
全部,
我将为用户输入一个长度为10,14,17个字符或包含逗号(任意长度)的字符串。脚本从那里开始,具体取决于输入的长度。当我使用各种可接受的长度或包含逗号进行测试时,脚本可以正常工作。但是,如果我输入一个不可接受的长度(并且没有逗号),我会继续获得''到LL模型''的打印语句而不是''不可接受的条目 - 拯救!''的声明。我做错了什么?
All,
I will have a user input a string that is either 10, 14, 17 characters long, or contains a comma (of any length). The script proceeds from there depending on the length entered. When I test with the various acceptable lengths or containing a comma, the script works. However, if I put in an unacceptable length (and without a comma), I keep getting the ''to LL model'' print statement instead of the ''Unacceptable entry -- bailing out!'' statement. What am I doing wrong?
推荐答案
全部,
我将为用户输入一个长度为10,14,17个字符或包含逗号(任意长度)的字符串。脚本从那里开始,具体取决于输入的长度。当我使用各种可接受的长度或包含逗号进行测试时,脚本可以正常工作。但是,如果我输入一个不可接受的长度(并且没有逗号),我会继续获得''到LL模型''的打印语句而不是''不可接受的条目 - 拯救!''的声明。我做错了什么?
All,
I will have a user input a string that is either 10, 14, 17 characters long, or contains a comma (of any length). The script proceeds from there depending on the length entered. When I test with the various acceptable lengths or containing a comma, the script works. However, if I put in an unacceptable length (and without a comma), I keep getting the ''to LL model'' print statement instead of the ''Unacceptable entry -- bailing out!'' statement. What am I doing wrong?
啊,我们非常感谢您的解释!非常感谢!!
Ah, the explanation is appreciated, and that works! Thanks so much!!
啊,这个解释很受欢迎,而且有效!非常感谢!!
Ah, the explanation is appreciated, and that works! Thanks so much!!
正如另一个例子,我走了另一条路线,使用正则表达式做了以下,看起来工作正常:
Just as another example, I went another route, using Regular Expressions and did the following, which seemed to work fine:
这篇关于用户输入字符串包含某些字符测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!