-3

I have number like 4.1.1.1 replace with 4_1_1_1

Please provide solution in jQuery.

Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Mayank Patel
  • 117
  • 2
  • 15
  • 5
    *"Please provide solution in Jquery."* How 'bout you do a ***minimum*** amount of research? This is not a remotely hard question to find the answer to. – T.J. Crowder Dec 31 '14 at 12:36
  • 1
    Why don't you search your question on google ? or try it on – Karthik Chintala Dec 31 '14 at 12:36
  • The suggested questions, when writing the title of the question, would already give enough answers to exactly this question – Andreas Dec 31 '14 at 13:04
  • possible duplicate of [How to replace all dots in a string using JavaScript](http://stackoverflow.com/questions/2390789/how-to-replace-all-dots-in-a-string-using-javascript) – Andreas Dec 31 '14 at 13:04
  • SO isn't a code factory where you make orders by specifying what you want coded and how you want it delivered. – charlietfl Dec 31 '14 at 15:55

2 Answers2

5

You don't even need help here from any library, this is just plain Javascript:

var str = "4.1.1.1";
alert(str.replace(/\./g, '_'));

Read about replace method of the String prototype and also about regular expressions you can use with it.

dfsq
  • 191,768
  • 25
  • 236
  • 258
0
var convertDotToDash = function(string) {
    return string.replace(/\./g,'_');
}

This is what @Solution mentioned. Just made it into a function

user1496463
  • 410
  • 3
  • 14