Solved

what is the use

Posted on 2013-12-26
4
186 Views
Last Modified: 2013-12-26
Dear all,
can anyone please tell me what this do:
var items = DataItems.replace("(?m)^[ \t]*\r?\n", "");

Open in new window

0
Comment
Question by:ethar1
  • 2
4 Comments
 
LVL 74

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 450 total points
ID: 39740224
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
 
LVL 7

Assisted Solution

by:dimmergeek
dimmergeek earned 50 total points
ID: 39740233
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
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 450 total points
ID: 39740250
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
 

Author Comment

by:ethar1
ID: 39740366
dear all,
could you please continue answer the question :
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28325842.html
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now