Skip to content Skip to sidebar Skip to footer

Target A Bell Character With A Regular Expression

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.

Solution 1:

/␇/ to match , /\\a/ to match \a

http://jsfiddle.net/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.

Solution 2:

str.match(/\u2407/) !== null//string contains ␇

Solution 3:

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.

Post a Comment for "Target A Bell Character With A Regular Expression"