我目前正在尝试解决上述问题。具体来说,我想检查字符串是否不包含"stream"这个单词,忽略大小写。
这是我的代码:
if (((gewaesser_name1.includes("Stream") == "false") ||
(gewaesser_name1.includes("stream") == "false")) &&
((gewaesser_name2.includes("Stream") == "false") ||
(gewaesser_name2.includes("stream") == "false")))
{var a= "..."}
代码显然无法正常工作,因为结果并不符合我的预期。
在使用以下语法变体之前,我还尝试使用 indexOf
方法:
The code does obviously not work as the results are not what I expect them to be.
I also tried to use the indexOf
method before using the following syntax variations:
gewaesser_name2.indexOf("stream") == -1
gewaesser_name2.indexOf("stream") < 0
对我来说,这些变化似乎都不起作用。请问有人能给我一个提示,问题出在哪里吗?我以前多次使用过 indexOf
方法,但总是用来检查字符串是否包含特定单词,而不是反过来。
if (!name.toLowerCase().includes("stream")) {..
- user1106925&&
,而不是||
。 - Barmar