javascript - 请问匹配最后一个空格后的内容的正则表达式怎么写?

WBOY
Release: 2016-06-06 20:27:50
Original
2016 people have browsed it

<code>请问匹配最后一个空格后的内容的正则怎么写?

或者说匹配最后一个空格前的内容的也可以。

我自己试了几种都没有用。

还有\s 的话,到底能不能匹配到中文的空格呢?
</code>
Copy after login
Copy after login

回复内容:

<code>请问匹配最后一个空格后的内容的正则怎么写?

或者说匹配最后一个空格前的内容的也可以。

我自己试了几种都没有用。

还有\s 的话,到底能不能匹配到中文的空格呢?
</code>
Copy after login
Copy after login

js:

<code>/\s+(\S*)$/</code>
Copy after login

关键:

\S 非空 $行尾

你的意思应该是半/全角空格吧?\s是可以匹配的。楼上的正则就是匹配空格后的内容的正则

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!