Hi, i tried to do not show "SPAM" in string below using that regex:
alert("{SPAM\nSPAM} _1_ {SPAM} _2_".replace(/{[\s\S]+}/gm, ""));
What i was supposed to see was "~1~ ~2~"
(or something like that) but i got just ~2~. Why?
...
Is there a way in C++ to remove/trim a trailing new line from a text file?
For example
content content
content content
content content
<- this line in the text file is empty and needs to go ->
...
It sounds like a pretty simple question but I can find the answer no where.
I have a post from a textarea. and I want to use the current facebook php library to do the following...
$description = $_POST['textarea_description'];
//magic happens
$attachment = array(
'access_token' => $token,
'message' => "$title",
'picture' => "$ima...
I'm writing a simple Perl script (on Windows) to download the response of a get request to a url to a file. Pretty straight-forward. Except when it writes to the output file, I get extra line breaks. So like instead of:
<head>
<title>title</title>
<link .../>
</head>
I get
<head>
<title>title</title>
<link .../>
</head>
...
I'm trying to read from a file and write into another. The problem arises when I'm trying to preserve newlines from the original file to the new one.
def caesar_encrypt(orig , shift):
enctextCC = open("CCencoded.txt" , 'w')
for i in range(len(orig)):
for j in range(len(orig[i])):
curr = orig[i][j]
if ord(cu...
I am trying to use 'gethostbyname'. If I hardcode a host name directly into the function call it works great. However, I am trying to pass user input into this function. I believe my problem may because the array I am passing to the function has many trailing whitespaces.
void connectHost(char *hostname)
{
int n;
//This ...
Hi,
Seems like a simple question, but I haven't been able to find a solid answer anywhere. I'm outputting a ton of HTML and find escaping "s to be error prone and hard to read, but I also want to have my HTML formatted nicely.
Want something like this (though I know this won't worK):
echo '<div id="test">\n';
echo '\t<div id="test-s...
I want to create a text file, than load it up without any newlines or spaces (This is for a simple RPG). So I want to test for all 3 major OS line separators, and than the current OS'(s?) one. I know I can get the current one using System.getProperty("line.separator"), but how can I get Linux, Mac, and Windows line separators and turn ...
I have a DB2 query in a shell script which return an integer value, but I am unable to store it in a variable.
temp1= echo db2 -x "select max(id) from work.work_tb"
I am getting this output when I run it, sh -x test.sh
db2 -x select max(id) from work.work_tb
echo 50
temp1=
50
So for some reason $temp1 is unable to get the value, ...
A php variable contains the following string:
<p>text</p>
<p>text2</p>
<ul>
<li>item1</li>
<li>item2</li>
</ul>
I want to remove all the new line characters in this string so the string will look like this:
<p>text</p><p>text2><ul><li>item1</li><li>item2</li></ul>
I've tried the following without success:
str_replace('\n', '', $st...
I'm trying to write a regular expression that replaces line feeds between certain areas of a text file, but only on plain text content (i.e. excludes text inside HTML attribute contents, like href) but not having much luck past the first part.
Example input:
AUTHOR: Me
DATE: Now
CONTENT:
This is an example. This is another example. <a ...
When opening a text based file in Visual Studio 2010 it will then write my edits with CRLF instead of the line ending format of the original file. How can I stop VS from doing this? Any half decent editor should have this capability.
What's worse is that since VS wrote the file with portions in CRLF, it then (when opening the file again...
I have a text area in HTML where the user can enter text, but when the form is submitted, and its passed to a php script which echo's it, there aren't any newlines. Knowing that HTML does that, I tried doing a preg_replace() before echoing it...
echo preg_replace("/\n/", "<br />", $_GET["text"]);
but still everything is on one lin...
Hi,
I'm trying to generate an excel file using html in php and responding with an excel Content-type. Everything works fine except new lines within a cell . They are not preserved.
I've tried ; ; \r\n ,chr(13).chr(10) and it didn't work.
I'm trying to get the same result from alt + enter from microsoft Excel .
I am generating in a ce...
I've seen the new line \n used 2 different ways in a few code examples I've been looking at. The first one being '\n' and the second being "\n". What is the difference and why would you use the '\n'?
I understand the '\n' represents a char and "\n" represents a string but does this matter?
...
I'm a little stuck. How do I remove multiple newlines which are in a row with one newline. There could be anything up to 20 newlines next to each other. For example
James said hello\n\n\n\n Test\n Test two\n\n
Would end up as:
James said hello\n Test\n Test two\n
...
If I have a textarea and I put in a newline, FireFox and IE 7/8 seem to store that as "\n". (i.e. if I do val.match(/\n/) it finds something, but val.match(/\r/) finds nothing) C# of course represents newlines as "\r\n". This leads to problems when we have maximum length restrictions, since every newline is counted as one character in th...