regular expression for matching exact words and dolar signs [duplicate]












0
















This question already has an answer here:




  • RegExp word boundary with special characters (.) javascript

    1 answer



  • Javascript Regex Word Boundary with optional non-word character

    2 answers




I am having problems writing proper regex in javascript that matches specific word (for example "world") which is not substring, but can be followed by special characters. My closest solution was



 /bworldb/gi 


which works fine, BUT what if that word is composed from special characters, for example "$$$"? In that case regex looks like this:



/b$$$b/gi


but this expression matches word a$$$a, but doesn't match $$$ which is exactly opposite of what it was supposed to match.



Here is example link: https://regex101.com/r/16BfSO/1










share|improve this question













marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 9:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • /b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

    – Wiktor Stribiżew
    Nov 16 '18 at 9:26


















0
















This question already has an answer here:




  • RegExp word boundary with special characters (.) javascript

    1 answer



  • Javascript Regex Word Boundary with optional non-word character

    2 answers




I am having problems writing proper regex in javascript that matches specific word (for example "world") which is not substring, but can be followed by special characters. My closest solution was



 /bworldb/gi 


which works fine, BUT what if that word is composed from special characters, for example "$$$"? In that case regex looks like this:



/b$$$b/gi


but this expression matches word a$$$a, but doesn't match $$$ which is exactly opposite of what it was supposed to match.



Here is example link: https://regex101.com/r/16BfSO/1










share|improve this question













marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 9:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • /b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

    – Wiktor Stribiżew
    Nov 16 '18 at 9:26
















0












0








0









This question already has an answer here:




  • RegExp word boundary with special characters (.) javascript

    1 answer



  • Javascript Regex Word Boundary with optional non-word character

    2 answers




I am having problems writing proper regex in javascript that matches specific word (for example "world") which is not substring, but can be followed by special characters. My closest solution was



 /bworldb/gi 


which works fine, BUT what if that word is composed from special characters, for example "$$$"? In that case regex looks like this:



/b$$$b/gi


but this expression matches word a$$$a, but doesn't match $$$ which is exactly opposite of what it was supposed to match.



Here is example link: https://regex101.com/r/16BfSO/1










share|improve this question















This question already has an answer here:




  • RegExp word boundary with special characters (.) javascript

    1 answer



  • Javascript Regex Word Boundary with optional non-word character

    2 answers




I am having problems writing proper regex in javascript that matches specific word (for example "world") which is not substring, but can be followed by special characters. My closest solution was



 /bworldb/gi 


which works fine, BUT what if that word is composed from special characters, for example "$$$"? In that case regex looks like this:



/b$$$b/gi


but this expression matches word a$$$a, but doesn't match $$$ which is exactly opposite of what it was supposed to match.



Here is example link: https://regex101.com/r/16BfSO/1





This question already has an answer here:




  • RegExp word boundary with special characters (.) javascript

    1 answer



  • Javascript Regex Word Boundary with optional non-word character

    2 answers








javascript regex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 16 '18 at 9:24









Tadej VozlicTadej Vozlic

9213




9213




marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 9:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Wiktor Stribiżew javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 9:25


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • /b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

    – Wiktor Stribiżew
    Nov 16 '18 at 9:26





















  • /b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

    – Wiktor Stribiżew
    Nov 16 '18 at 9:26



















/b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

– Wiktor Stribiżew
Nov 16 '18 at 9:26







/b$$$b/gi will match $$$ only when enclosed with word chars. Use /B$$$B/gi. A more generic soluon is here (in case your input is dynamic).

– Wiktor Stribiżew
Nov 16 '18 at 9:26














0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma