I am matching words that begin with certain prefixes.
This regex is working well for me but I am having trouble applying multiple terms in one match.
- matching prefix ‘re’:
/re\S+/g;
I thought it would work with
- matching prefix ‘re’ and ‘http’:
/(re|http)\S+/g;
However the latter only returns matches from the second term.
Here is the full code:
function replacePrefix(input){
var re = /(#)\S+/g;
var specials = [];
var match;
while(match = re.exec(input)){
$('#text').html(input.replace(specials[0], "<span class='special'>"+specials[0]+"</span>"));
}
}
1 Answer