Varun Chadha
Varun Chadha

Reputation: 376

Replace characters in JavaScript

I have a string

"vtn:o:result:/buffer/get/"

I want to replace character "o" with "b" So that resultant string is

"vtn:b:result:/buffer/get/"

I am trying following method:

var alphabet = "vtn:o:result:/buffer/get/";
alphabet = alphabet.replace(/:o.*:/, 'b');

But not getting the required result. I don't want to use jQuery, just JavaScript.

Upvotes: 0

Views: 76

Answers (1)

atmd
atmd

Reputation: 7490

You should be able to do

 alphabet.replace('o', 'b');

Upvotes: 1

Related Questions