• Welcome to Baben's blog that year. I'm glad to meet you at the right age!
  • Due to the theme, the QQ login partner displays the default avatar in the comments. Please go to the personal center to upload the avatar again.

Js uses split to split text by carriage return, line feed or space

Code Notes barben Five years ago (August 23, 2019) 12469 views 1 comment

Split text using split method

When writing an item, one function is to cut the text into arrays by spaces or newlines. In fact, only one sentence is needed

 var phone = "110 119 120"; phone.split(/[\s\n]/); //  ["110", "119", "120"]

The effect is as follows


Eight blogs that year, we have been
If the author does not indicate that it is an original article, please indicate the link and source of this article for reprinting
Js uses split to split text by carriage return, line feed or space- https://www.barben.cn/code/577.html
Like( eight )
Post my comments
Cancel comment
expression Mapping Bold Strike through Center Italic

You need to bring your nickname and email with you in the review of Eight Books that year!

  • Nickname (required)
  • Email (required)
  • website
Successfully captured one Only rare elves
  1. Non-technical passing.
    repostone 2019-08-29 16:25 reply