我目前有这种正则表达式替换功能
SELECT TOP 100 "public".ids.ids
FROM "public".basic
JOIN "public".ids ON "public".basic.oid = "public".ids.oidref
WHERE "public".basic.main_id = 'm13'
例如
var regex = new RegExp(value, 'gi');
var return = item.replace(regex, function(match) { return "<strong>" + match + "</strong>" });
其中
value = 'a';
它返回='C a t狗 A pple';
我想要的
所以结果应该是
item = 'Cat Dog Apple';
答案 0 :(得分:2)
您正在寻找
\ba\w+
JavaScript
中:
let items = ['Cat', 'Dog', 'Apple', 'advertisement', 'New York'];
let regex = /\ba\w+/gi;
items.forEach(function(item) {
let new_item = item.replace(regex, function(match) {
return "<strong>" + match + "</strong>";
});
console.log(new_item);
});