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

Who is Participating?
käµfm³d 👽Connect With a Mentor 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.
käµfm³d 👽Connect With a Mentor 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.
dimmergeekConnect With a Mentor Commented:
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
ethar1Author Commented:
dear all,
could you please continue answer the question :
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.