• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

what is the use

Dear all,
can anyone please tell me what this do:
var items = DataItems.replace("(?m)^[ \t]*\r?\n", "");

Open in new window

0
ethar1
Asked:
ethar1
  • 2
3 Solutions
 
käµfm³d 👽Commented:
It replaces any number ( * )--including zero--of spaces and tabs ( [ \t] ) found just before a newline character ( \n ) with an empty string ( "" ). The newline may be optionally ( ? ) preceded by a carriage return ( \r ).

This is what is known as a regular expression. The replace method accepts such as a parameter. You can read more at www.regular-expressions.info.
0
 
dimmergeekCommented:
I'm  not too great with regexes, but I believe this will replace all tabs and newlines with and empty character string ("").  The (?m) tells the regex to match at all line breaks
0
 
käµfm³d 👽Commented:
but I believe this will replace all tabs and newlines
It will match all tabs (and spaces) that occur immediately before a newline, not simply all tabs (and spaces). To say that all newlines will be replaced is accurate.
0
 
ethar1Author Commented:
dear all,
could you please continue answer the question :
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28325842.html
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now