Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regex to remove only the leading white spaces - modified

807589Oct 24 2008 — edited Oct 26 2008
Sorry, 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 "&nbsp");
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 23 2008
Added on Oct 24 2008
17 comments
2,041 views