Javascript function to remove leading dot

javascript, regex, replace

Solution

The following replaces a dot in the beginning of a string with an empty string leaving the rest of the string untouched:

a.replace(/^\./, "")

Problem

I have a javascript string which have a leading dot. I want to remove the leading dot using javascript replace function. I tried the following code. ``` var a = '.2.98»'; document.write(a.replace('/^(\.+)(.+)/',"$2")); ``` But this is not working. Any Idea?

Original source