I have this Regex below that I use together with Textcomplete, check if someone writes #
or @
together with a parameter
Regex:
/\B#(\w+)$/
I load some names from my database, and you can search them with either #
or @
. Lets say that in the database it contains Stackoverflow.
If I write #Stackoverflow it works since I wrote a big S letter. but if I write #stackoverflow it dont work because of the small s letter.
My question is how can I change the regex so it ignore small or big letters?
Updated with script
$('textarea').textcomplete([
{ // html
mentions: Companies,
match: /\B#(\w+)\i$/,
search: function (term, callback) {
callback($.map(this.mentions, function (mention) {
return mention.indexOf(term) === 0 ? mention : null;
}));
},
template: function (value) {
return '<img src="/emoji/' + value + '.png"></img>' + value;
},
index: 1,
replace: function (mention) {
return '#' + mention + ' ';
}
}
],
{ appendTo: 'body' }).overlay([
{
match: /\B#\w+/g,
css: {
'background-color': '#d8dfea',
}
}
])
To show you that It dont work, I created it at codePen.