Skip to content

Instantly share code, notes, and snippets.

@jikeytang
Created May 24, 2014 23:44
Show Gist options
  • Save jikeytang/c90a91f0293c06e5774e to your computer and use it in GitHub Desktop.
Save jikeytang/c90a91f0293c06e5774e to your computer and use it in GitHub Desktop.
[ Javascript ] - 20140525-题目1
翻转句子中单词的顺序
如:输入“I am a diaosi”,则输出“diaosi a am I”。
PS:
1. 回复时注意加上下面这句话,才会有语法高亮或格式缩进。
```javascript
// you code
```
2. 粘贴代码时请使用shift+tab,缩进前面的空白。
@chriswenwu
Copy link

str="i am is may dsds a d d f fsxx aa dsf";
str.match(/(\b\w+\b)+/g).reverse();

@jikeytang
Copy link
Author

天牛答案

'q we err tyy'.split(/\s+/).resever().join(' ')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment