admin管理员组文章数量:1026989
I noticed that there's a regular expression character for bell. I can't match though. I read what this character is on wikipedia, but I don't understand how to find it in a regex.
<input type="text" value="␇" />
<input type="text" value="\a" />
/
I noticed that there's a regular expression character for bell. I can't match though. I read what this character is on wikipedia, but I don't understand how to find it in a regex.
<input type="text" value="␇" />
<input type="text" value="\a" />
http://jsfiddle/umQq8/
Share Improve this question asked Aug 2, 2013 at 14:07 12527481252748 15.4k34 gold badges117 silver badges242 bronze badges3 Answers
Reset to default 4/␇/
to match ␇
, /\\a/
to match \a
http://jsfiddle/umQq8/1/
The wikipedia article is about the bell character but the character is U+2407 SYMBOL FOR BELL
, not the bell character
In your JSFiddle, you are writing \a
in HTML, but in HTML the backslash escapes are not interpreted in any special way. In Javascript, backslash is a meta-character but the sequence \a
is unrecognized and it will be treated as literal backslash and a. If you want actual bel character in your form, you need to write actual bel character (kinda hard because it's invisible) or you can't because those are illegal.
str.match(/\u2407/) !== null //string contains ␇
In your IF statement, you can search for either \a
(you have that in there already and it returns true) or the \u2407
character, which matches the bell unicode character.
I noticed that there's a regular expression character for bell. I can't match though. I read what this character is on wikipedia, but I don't understand how to find it in a regex.
<input type="text" value="␇" />
<input type="text" value="\a" />
/
I noticed that there's a regular expression character for bell. I can't match though. I read what this character is on wikipedia, but I don't understand how to find it in a regex.
<input type="text" value="␇" />
<input type="text" value="\a" />
http://jsfiddle/umQq8/
Share Improve this question asked Aug 2, 2013 at 14:07 12527481252748 15.4k34 gold badges117 silver badges242 bronze badges3 Answers
Reset to default 4/␇/
to match ␇
, /\\a/
to match \a
http://jsfiddle/umQq8/1/
The wikipedia article is about the bell character but the character is U+2407 SYMBOL FOR BELL
, not the bell character
In your JSFiddle, you are writing \a
in HTML, but in HTML the backslash escapes are not interpreted in any special way. In Javascript, backslash is a meta-character but the sequence \a
is unrecognized and it will be treated as literal backslash and a. If you want actual bel character in your form, you need to write actual bel character (kinda hard because it's invisible) or you can't because those are illegal.
str.match(/\u2407/) !== null //string contains ␇
In your IF statement, you can search for either \a
(you have that in there already and it returns true) or the \u2407
character, which matches the bell unicode character.
本文标签: javascriptTarget a bell character with a regular expressionStack Overflow
版权声明:本文标题:javascript - Target a bell character with a regular expression - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745567536a2156542.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论