經安全檢測,此網站為安全網站,請放心前往原始網址!

JavaScript: String.trim() - JavaScripter.net - JavaScript FAQ, quizzes, games, and more

Question: How do I trim leading and trailing spaces of a string? Answer: To remove all leading and trailing spaces from a string str, you can use this code: str = str.replace(/^\s+|\s+$/g,'') This code example uses the regular expression /^\s+

www.javascripter.net

網址安全性掃描由 google 提供