Possible Duplicate:
How do I trim a string in javascript?
Using JavaScript without any frameworks how would you trim line breaks? Trim as being defined by PHP, removing the leading and ending line breaks while preserving line breaks after the first non-white-space character and until though not beyond the last non-white-space character.
By default most people will want to know how to remove both leading/ending line breaks as well as white-space spaces too though some may want to retain the white-space spaces while trimming just the white-space line-breaks. It also generally helps to see two working examples and how they relate when they both work for people learning code, so I'm looking for trimming both white-space line-breaks and white-space spaces.
It'd be good also to see how to trim just the leading/ending line breaks while preserving white-space spaces (which may or may not be included in the main answer).