• Welcome to the eight year blog, I'm glad to meet you at the right age!
  • Due to the theme, QQ login partners will display the default avatar in the comments. Please go to the personal center and upload the avatar again.

JS uses split to break text by carriage return or space

Code Notes barben One year ago (August 23, 2019) 1730 views 1 comment

Split method is used for text segmentation

When writing a project, there is a function to cut the text into an array according to the space or newline

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

The effect is as follows


Eight blogs that year, we've been there all the time
If the author does not indicate the original article, please indicate the link and source of this article
JS use split to break text by carriage return or space - https://www.barben.cn/code/577.html
Like it( eight )
Post my comments
Cancel comment
expression Mapping Bold Strikethrough Center Italics

You need to bring your nickname and email with you in the year of eight!

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