• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • 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

  • 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.
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
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.
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.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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