|
|
Q241 How do I strip leading and trailing blanks off of a string (without writing a function to treat character by character)?
irt.org | Knowledge Base | JavaScript | Text | Q241 [ previous next ] Q241 How do I strip leading and trailing blanks off of a string (without writing a function to treat character by character)?The following demonstrates an efficient character by character method of stripping leading and trailing spaces from a form field value, followed by a method supported by JavaScript1.2 browsers using regular expressions. The method chosen depends on the JavaScript version supported by the browser being used.
the following was submitted by Jay Dunning The following is much easier to code than either the substring or regexp approaches. It is faster than the substring algorithm. Although it is slower than regexp, it will work in older interpreters:
Feedback on 'Q241 How do I strip leading and trailing blanks off of a string (without writing a function to treat character by character)?' |
-- div -->
|