regex - Replace all occurrences of the dot character with an underscore character in javascript -



regex - Replace all occurrences of the dot character with an underscore character in javascript -

in javascript, need replace occurrences of dot character (.) underscore character (_) if except lastly one.

this look replaces occurrences of dot character (.) including lastly 1 underscore character (_) i'm trying figure out how alter leaves lastly (.) character alone.

str.replace(/\./g, '_');

thanks !!

steve

the fun look aheads.

"12.34.56.78".replace(/\.(?=[^.]*\.)/g,"_")

javascript regex pattern-matching

Comments

Popular posts from this blog

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -