The pattern html|php|css|java(script)?|C finds programming languages.
But it gives false matches, see below:
var re = /html|php|css|java(script)?|C/gi var str = "Javallo, PHP specialist" alert( str.match(re) ) // 'Java', 'PHP', 'c'
…But obviously, there is only PHP language in the text. Fix the regexp to make it match correctly.
Решение
Решение
To filter, we need to match languages only if they are standalone words. A word boundary check helps here: \b(html|php|css|java(script)?)\b.
var re = /\b(html|php|css|java(script)?|C)\b/gi var str = "Javallo, PHP specialist" alert( str.match(re) ) // 'Java', 'PHP', 'c'
#263