Regex to remove only the leading white spaces - modified
807589Oct 24 2008 — edited Oct 26 2008Sorry, I am posting the same question again because the previous one was altered because I was using the in the text which was replaced with a blank space. Here is the updated one:
Hi,
I am trying to use a regular expression to replace all and only the leading white spaces from a string with <ampersand>nbsp; to generate the html code. For now, I am using:
lsModified = lsColName.replaceAll("\\s " ");
This works but it replaces all the spaces in between the string. Is there a way to just remove the leading white space (and all of leading white spaces) from the string using regex? If I use "^\\s", it removes only the first one which will not work for me. Please let me know how this could be done.
Thanks for your help in advance