I've got this:
var quoted_text = window.getSelection;
For example:
Accepting the Terms of Service
The Stack Exchange Network (the “Network”) is a set of related Internet sites and other applications for questions and answers, owned and operated by Stack Exchange Inc. (“Stack Exchange”), a Delaware corporation. Please read these terms of service (“Agreement”) carefully before using the Network or any services provided on the Network (collectively, “Services”). By using or accessing the Services, you agree to become bound by all the terms and conditions of this Agreement. If you do not agree to all the terms and conditions of this Agreement, do not use the Services. The Services are accessed by You (“Subscriber” or “You”) under the following terms and conditions: 1. Access to the Services
Subject to the terms and conditions of this Agreement, Stack Exchange may offer to provide the Services, as described more fully on the Network, and which are selected by Subscriber, solely for Subscriber’s own use, and not for the use or benefit of any third party. Services shall include, but not be limited to, any services Stack Exchange performs for Subscriber, as well as the offering of any Content (as defined below) on the Network. Stack Exchange may change, suspend or discontinue the Services at any time, including the availability of any feature, database, or Content. Stack Exchange may also impose limits on certain features and services or restrict Subscriber’s access to parts or all of the Services without notice or liability. Stack Exchange reserves the right, at its discretion, to modify these Terms of Service at any time by posting revised Terms of Service on the Network and by providing notice via e-mail, where possible, or on the Network. Subscriber shall be responsible for reviewing and becoming familiar with any such modifications. Use of the Services by Subscriber following such modification constitutes Subscriber's acceptance of the terms and conditions of this Agreement as modified.
How can i make in array from that text by newlines?
I need to paste in the begining of each line simbols "> ", how to do that?
The string in JavaScript can be converted into a character array by using the split() and Array. from() functions.
To add a line break in array values for every occurrence of ~, first split the array. After splitting, add a line break i.e. <br> for each occurrence of ~.
The newline character is \n in JavaScript and many other languages. All you need to do is add \n character whenever you require a line break to add a new line to a string.
Use the join() method to combine the array into one string and separate each entry by by <br> to print array on separate lines in JavaScript.
Use split()
Fore example
str = "abc\ndef"; console.log(str.split("\n"));
will print out
["abc", "def"]
Use JavaScript .split()
function to create an array with elements split by '\n' and then manually iterate through that array and add '<' for each item. The following code may help :
var str="How\nare\nyou\ndoing\ntoday?"; var n = str.split("\n"); for(var x in n){ n[x]= '>'+n[x]; alert(n[x]); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With