var str="asd-0.testing";
var regex = /(asd-)\d(\.\w+)/;
str = str.replace(regex, "$11$2");
console.log(str);
Or if you’re sure there won’t be any other digits in the string:
var str="asd-0.testing";
var regex = /\d/;
str = str.replace(regex, "1");
console.log(str);
More Related Contents:
- Replace multiple strings with multiple other strings
- Get Substring between two characters using javascript
- Fastest way to check a string contain another substring in JavaScript?
- RegEx for match/replacing JavaScript comments (both multiline and inline)
- Remove whitespace and line breaks between HTML elements using jQuery
- Replace a Regex capture group with uppercase in Javascript
- JavaScript .replace only replaces first Match [duplicate]
- How to replace last occurrence of characters in a string using javascript
- How to trim a file extension from a String in JavaScript?
- JavaScript replace/regex
- Regex to extract substring, returning 2 results for some reason
- Insert space before capital letters
- JavaScript text between double quotes
- Why can’t I use accented characters next to a word boundary?
- JavaScript replace \n with [duplicate]
- Need Pattern for password field?
- Detect URLs in text with JavaScript
- Regular Expression to get a string between parentheses in Javascript
- How do I check if string contains substring? [duplicate]
- split string only on first instance of specified character
- javascript regex split produces too many items
- Remove HTML comments with Regex, in Javascript
- Create RegExps on the fly using string variables
- Regular expression for URL validation (in JavaScript)
- Javascript fuzzy search that makes sense
- How to get possibly overlapping matches in a string
- how to extract floating numbers from strings in javascript
- Javascript unicode string, chinese character but no punctuation
- JavaScript remove ZERO WIDTH SPACE (unicode 8203) from string
- How to replace curly quotation marks in a string using Javascript?