According to the Javascript standard, String.replace
isn’t supposed to modify the string itself. It just returns the modified string. You can refer to the Mozilla Developer Network documentation for more info.
You can always just set the string to the modified value:
variableABC = variableABC.replace('B', 'D')
Edit: The code given above is to only replace the first occurrence.
To replace all occurrences, you could do:
variableABC = variableABC.replace(/B/g, "D");
To replace all occurrences and ignore casing
variableABC = variableABC.replace(/B/gi, "D");
Related Posts:
- I can´t install nodemon globally, “nodemon” not recognized
- How can I update NodeJS and NPM to the next versions?
- How can I update npm itself?
- How do I update Node.js?
- How to install a previous exact version of a NPM package?
- How to replace all occurrences of a string in JavaScript
- How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’
- How to fix ‘Unchecked runtime.lastError: Could not establish connection. Receiving end does not exist.’
- How to solve npm error “npm ERR! code ELIFECYCLE”
- How to solve npm error “npm ERR! code ELIFECYCLE”
- npm check and update package if needed
- What is the file node.exe for?
- Node.js version on the command line? (not the REPL)
- Can not find module “@angular-devkit/build-angular”
- Node.exe Stuck at 100% CPU
- After command npm start “Missing script:start” error
- sudo: npm: command not found
- Discord API error when trying to send one command at discord using JavaScript client
- How to resolve Nodejs: Error: ENOENT: no such file or directory
- bash: npm: command not found?
- Node.js getaddrinfo ENOTFOUND
- How do I debug error ECONNRESET in Node.js?
- Node.js getaddrinfo ENOTFOUND
- How do I debug error ECONNRESET in Node.js?
- Does anyone knows what “rimraf” means?
- How can I completely uninstall nodejs, npm and node in Ubuntu [closed]
- Please run `npm cache clean`
- How to use operator ‘-replace’ in PowerShell to replace strings of texts with special characters and replace successfully
- What is the difference between npm install and npm run build?
- What is “export default” in JavaScript?
- What is Express.js?
- How do I resolve “Cannot find module” error using Node.js?
- npm ERR cb() never called
- Missing write access in mac to /usr/local/lib/node_modules
- What is the difference between __dirname and ./ in node.js?
- NPM clean modules
- ‘node’ is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova
- How can the default node version be set using NVM?
- What does body-parser do with express?
- Replace part of a string with another string
- node.js, Error: Cannot find module ‘express’
- env: node: No such file or directory in mac
- mongoError: Topology was destroyed
- NPM Start not starting local server
- Error: unable to verify the first certificate in nodejs
- node.js, Error: Cannot find module ‘express’
- nodemon – app crashed – waiting for file changes before starting
- What does the ELIFECYCLE Node.js error mean?
- “Topology was destroyed” when using MongoDB with native driver and Express.js
- Error: getaddrinfo ENOTFOUND in nodejs for get call
- How do I resolve “Cannot find module” error using Node.js?
- Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
- What is the –save option for npm install?
- how to use CryptoJS in javascript
- env: node: No such file or directory in mac
- Node Version Manager install – nvm command not found
- nodemon not working: -bash: nodemon: command not found
- Error: Cannot find module ‘../lib/utils/unsupported.js’ while using Ionic
- Failed to load resource: net::ERR_CONNECTION_REFUSED : Nodejs
- Where is nodejs log file?
- npm install not working in windows
- nodemon not found in npm
- SyntaxError: Unexpected token import – Express
- how to replace quotation marks with \”
- Mongoose: findOneAndUpdate doesn’t return updated document
- nodemon not found in npm
- How to replace all double quotes to single quotes using jquery?
- Best way to replace multiple characters in a string?
- Error: No default engine was specified and no extension was provided
- Angular – ng: command not found
- How can I wait In Node.js (JavaScript)? l need to pause for a period of time
- How to downgrade Node version
- How to change to an older version of Node.js
- Significance of port 3000 in Express apps
- ExpressJS – throw er Unhandled error event
- NodeJS / Express: what is “app.use”?
- Discord.js sending a message to a specific channel
- The difference between “require(x)” and “import x”
- NodeJS – What does “socket hang up” actually mean?
- npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
- Why am I getting “Error socket hang up” response?
- Error: EACCES: permission denied
- What does the ELIFECYCLE Node.js error mean?
- How to Create and Use Enum in Mongoose
- What does the “as” keyword do?
- “Client network socket disconnected before secure TLS connection was established”, node 10
- How to write a .nvmrc file which automatically change node version
- How can I remove a character from a string using JavaScript?
- What Are “npm run dev” and “npm run prod”
- Find the version of an installed npm package
- First Heroku deploy failed `error code=H10`
- node.js: how to use setInterval and clearInterval?
- “npm config set registry https://registry.npmjs.org/” is not working in windows bat file
- Best way to replace multiple characters in a string?
- Git Bash Command on Windows, yarn command not found
- Node forever /usr/bin/env: node: No such file or directory
- How to get GET (query string) variables in Express.js on Node.js?
- How do I uninstall a package installed using npm link?
- What is Procfile? and Web and Worker
- What is Procfile? and Web and Worker