I am looking for a regex yielding to characters which are not word-characters nor a soft hyphen (U+00AD).
This will give me characters which are not word-characters:
((?=\W).)
But what about the soft hyphen character? What is the correct regex?
You can do this:
[^\w\u00AD]
(NOT a word or soft hyphen)
I created a quick and dirty last_symbol()
function:
function last_symbol(str) {
var result = str.match(/([^\w\u00AD])[\w\u00AD]*$/);
return (result == null) ? null : result[1]; }
last_symbol('hello') // null
last_symbol('hell!') // '!'
last_symbol('hell!o$') // '$'