0

I want to replace string containing b- with bst-. The edge cases are b- should not be preceded by any letter.

input = "b-picker-wrap b-active bob-state-default .b-picker /b-pic";

output = "bst-picker-wrap bst-active bob-state-default .bst-picker /bst-pic";

Prakash Gupta
  • 203
  • 1
  • 4
  • 13

1 Answers1

1

Use the following approach:

var input = "b-picker-wrap b-active bob-state-default .b-picker /b-pic",
    result = input.replace(/\bb-/g, "bst-");
    
console.log(result);
  • \b - word boundary
RomanPerekhrest
  • 88,541
  • 4
  • 65
  • 105