JavaScript正则表达式空白字符 [英] JavaScript regex whitespace characters

查看:66
本文介绍了JavaScript正则表达式空白字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经做了一些搜索,但是我找不到JavaScript正则表达式中\s中包含的空格字符的确切列表。

I have done some searching, but I couldn't find a definitive list of whitespace characters included in the \s in JavaScript's regex.

我知道我可以依赖空格,换行,回车和制表符作为空白,但我认为,因为JavaScript传统上只用于浏览器,可能是URL编码的空格和& nbsp; %20

I know that I can rely on space, line feed, carriage return, and tab as being whitespace, but I thought that since JavaScript was traditionally only for the browser, maybe URL encoded whitespace and things like   and %20 would be supported as well.

JavaScript的确切考虑因素正则表达式编译器?如果浏览器之间存在差异,我只关心webkit浏览器,但知道任何差异会很好。那么,node.js呢?

What exactly is considered by JavaScript's regex compiler? If there are differences between browsers, I only really care about webkit browsers, but it would be nice to know of any differences. Also, what about node.js?

推荐答案

HTML!= Javascript。 Javascript完全是字面值,%20是%20,& nbsp; 是一串字符& n b s p和;对于字符类,我认为几乎所有perl中的RegEx都适用于JS(你不能做命名组等)。

HTML != Javascript. Javascript is completely literal, %20 is %20 and   is a string of characters & n b s p and ;. For character classes I consider nearly every that is RegEx in perl to be applicable in JS (you can't do named groups etc).

http://www.regular-expressions.info/javascript.html 是我使用的参考资料。

http://www.regular-expressions.info/javascript.html is the refernece I use.

这篇关于JavaScript正则表达式空白字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆