Removal of New Line Break and Tab/Indentation in JavaScript

Here is the best possible coding for removal of newline break and tab/indentation:

; for (var i=0; i‹ txt.length; i++) txt = txt.replace('\n', ' ')
; for (var i=0; i‹ txt.length; i++) txt = txt.replace('\t', ' ')

This approach avoids the possible non-working of method .search() and RegExp. For details please refer to http://koncordpartners.blogspot.com/2010/02/deal-with-literals-and-escape-sequences.html

No comments:

Post a Comment

Labels