📌  相关文章
📜  如果单词包含空格使用 jquery 检测 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:25.103000             🧑  作者: Mango

代码示例1
What you have will find a space anywhere in the string, not just between words.

If you want to find any kind of whitespace, you can use this, which uses a regular expression:

if (/\s/.test(str)) {
    // It has any kind of whitespace
}

\s means "any whitespace character" (spaces, tabs, vertical tabs, formfeeds, line breaks, etc.), and will find that character anywhere in the string.