Search Results

Search found 186 results on 8 pages for 'newlines'.

Page 2/8 | < Previous Page | 1 2 3 4 5 6 7 8  | Next Page >

  • Lexing newlines in scala StdLexical?

    - by Nick Fortescue
    I'm trying to lex (then parse) a C like language. In C there are preprocessor directives where line breaks are significant, then the actual code where they are just whitespace. One way of doing this would be do a two pass process like early C compilers - have a separate preprocessor for the # directives, then lex the output of that. However, I wondered if it was possible to do it in a single lexer. I'm pretty happy with writing the scala parser-combinator code, but I'm not so sure of how StdLexical handles whitespace. Could someone write some simple sample code which say could lex a #include line (using the newline) and some trivial code (ignoring the newline)? Or is this not possible, and it is better to go with the 2-pass appproach?

    Read the article

  • How to remove all of the html whitespace/newlines of a NSString

    - by Kyriakos Leivadas
    i've got a problem and i hope someone can solve it. I parsed some html to a nsstring and im trying to trim all of the characters and keep some specific words. The problem is that i trimmed all the characters from the nsstring that i didnt want but the weird thing is that i cant get rid of all the whitespace. i used all the techniques i read from other answers but still some whitespace remains. here is my code -(void)requestFinished:(ASIHTTPRequest *)request{ NSString *htmlData = [request responseString]; NSCharacterSet *garbage = [NSCharacterSet characterSetWithCharactersInString:@"qazwsxedcrfvtgbyhnujmik,ol.p;/[]'QAZWSXEDCRFVTGBYHNUJMIKOLP()\"-1234567890#{}=:+_&!`<>"]; //im doing this to remove all characters except non-english chars htmlData = [htmlData compomentsSeparatedByCharactersInSet:garbage ]compomentsJoinedByString:@""]; htmlData = [htmlData stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; htmlData = [htmlData stringByReplacingOccurencesOfString:@"[\n\t\r ]+" withString@""]; htmlData = [htmlData stringByReplacingOccurencesOfString:@" " withString:@""]; NSLog(@"%@",htmlData); } i get this result: nonenglishwordsnonenglishwords nonenglishwordsnonenglishwords (whitespace or new lines in middle remains) thank you.

    Read the article

  • Bash: how to supress newlines?

    - by gilgongo
    I'm trying to extract fields from a pipe-delimited file and provide them as arguments to an external program in a loop. The file contains lines like this: value1|value2 value3|value4 So I came up with: while read line; do echo -n "${line}" | awk -F '|' '{print $1}'; echo -n " something "; echo -n "${line}" | awk -F '|' '{print $2}'; echo " somethingelse"; done < <(cat $FILE) I want to see the following output: value1 something value2 somethingelse value3 something value4 somethingelse But instead I'm getting: value1 something value2 somethingelse value3 something value4 somethingelse Perhaps I shouldn't be using echo?

    Read the article

  • Remove newlines and spaces

    - by Cosmin
    How can I remove newline between <table> .... </table> and add \n after each ex: <table border="0" cellspacing="0" cellpadding="0" width="450" class="descriptiontable"><tr> <td width="50%" valign="top"> <span class="displayb">Model Procesor:</span> Intel Celeron<br><span class="displayb">Frecventa procesor (MHz):</span> 2660<br><span class="displayb">Placa Video:</span> Intel Extreme Graphics 2<br><span class="displayb">Retea integrata:</span> 10/100Mbps, RJ-45<br><span class="displayb">Chipset:</span> Intel 845G<br> </td> <td width="50%" valign="top"> <span class="displayb">Capacitate RAM (MB):</span> 512<br><span class="displayb">Tip RAM:</span> DDR<br> </td> </tr></table> and become : <table border="0" cellspacing="0" cellpadding="0" width="450" class="descriptiontable"><tr><td width="50%" valign="top"><span class="displayb">Model Procesor:</span> Intel Celeron<br><span class="displayb">Frecventa procesor (MHz):</span> 2660<br><span class="displayb">Placa Video:</span> Intel Extreme Graphics 2<br><span class="displayb">Retea integrata:</span> 10/100Mbps, RJ-45<br><span class="displayb">Chipset:</span> Intel 845G<br></td><td width="50%" valign="top"><span class="displayb">Capacitate RAM (MB):</span> 512<br><span class="displayb">Tip RAM:</span> DDR<br></td></tr></table>\n s.

    Read the article

  • Convert Text with newlines to a List<String>

    - by Vaccano
    I need a way to take a list of numbers in string form to a List object. Here is an example: string ids = "10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19"; List<String> idList = new List<String>(); idList.SomeCoolMethodToParseTheText(ids); <------+ | foreach (string id in idList) | { | // Do stuff with each id. | } | | // This is the Method that I need ----------------+ Is there something in the .net library so that I don't have to write the SomeCoolMethodToParseTheText myself?

    Read the article

  • Preg_replace regex, newlines, connection resets

    - by bob_the_destroyer
    I have mixed html, custom code, and regular text I need to examine and change frequently on several, long wiki pages. I'm working with a proprietary wiki-like application and have no control over how the application functions or validates user input. The layout of pages that users add must follow a very specific standard layout and always include very specific text in only certain places - a standard which frequently changes. If users add pages that are so far out of the standard, they will be deleted. The fact that all this is obviously a complete waste of time when alternative platforms to do exactly what's needed here exist is already understood. I've built a PHP based API to automate this post-validation and frequent restandardization process for me. I've been able set up regex patterns to handle all this mixed text, and they all work fine for handling single lines. The problem I have is this: Poorly formed regex against long text with line breaks can lead to unexpected results, such as connection resets. I have no access to server-side logs to troubleshoot. How do I overcome this? This is just one example of what I currently have: {column} and {section} tags I'm searching for below can have any number of attributes, and wrap any text. {section} may or may not exist and may or may not be one or more lines under {column}, but it has to be wrapped inside {column}. {column} itself may or may not exist, and if it doesn't, I don't care. I want to grab the inner section contents and wrap it in an html div tag. I can't recall the exact pattern I'm using offhand at the moment, but it's close enough... $pattern = "/\{column:id=summary([|]?([a-zA-Z0-9-_ ]+[:][a-zA-Z0-9-_ ]+[ ]?))\}(.*)({section([|]([a-zA-Z0-9-_ ]+[:][a-zA-Z0-9-_ ]+[ ]?))\}(.*)\{section\}(.*))?{column\}/s"; $replacement = "{html}<div id='summary'$7</div{html}"; $text = preg_replace($pattern, $replacement, $subject); Handling the {column} and {section} attributes and passing only valid HTML parameters to the new html div or a subtext of it is itself a challenge, but my main focus above right now is getting that (.*) value within {section} above without causing a connection reset. Any pointers?

    Read the article

  • file content into unix variable with newlines

    - by Hugo
    I have a text file test.txt with the following content: text1 text2 And I want to assign the content of the file to a UNIX variable but when I do this: testvar=$(cat test.txt) echo $testvar the reult is: text1 text2 instead of text1 text2 Can someone suggest me a solution for this?

    Read the article

  • Perl -e insert new line

    - by lydonchandra
    Hi If I do this in bash perl -e '$x; $y' Is there any character that can behave like a new line? i.e. I want to do perl -e '$x; some_chars_as_new_line $y' where perl interpreter actually sees an actual new line. $x; $y; Many thanks

    Read the article

  • Proper line-ending for an open-source PHP project

    - by Mahdi
    What is the proper line-ending preferences for an open-source web project? Obviously it includes source code of PHP, HTML, CSS and Javascript. The source code is managing via Github now, and there are Windows (8 & 7), Linux (Ubuntu) and OSX developers inside the team, which means all the major operating systems. P.S. We are using "Windows" CRLF line-ending, plus "UTF-8 without BOM" right now, without facing any problem, however I think it might be better to use "*nix/OSX" LF style. I heard some stories about the problems that caused by the additional "CR" on Linux or OS X.

    Read the article

  • How to print new line character with echo?

    - by Summer_More_More_Tea
    I dump a string with hexdump like this 2031 3334 2e30 0a32 2032 3331 302e 000a. It is clear that 0x0a is new line character, however, when I try to echo this string out, I always got 1 430.2 2 13.0 -- the new line is replaced with a space, even I use the -e flag. What may be the problem? Does the tailing \0 ruin the output? Is there any alternatives to print 0x0a a new line? Thanks and Best regards.

    Read the article

  • Issues Converting Plain Text Into Microsoft Word Bulleted Lists

    - by user787832
    I'm a programmer. I hate status reports. I found a way to live with it. While I am working in my IDE ( Visual Slickedit ) I keep a plain text file open in one of the file/buffer tabs. As I finish things I just jot down a quick note into that file. At the end of the week that becomes my weekly status report. Example entries: The Datatables.net plugin runs very slowly in IE 8 with more than 2,000 records. I changed the way I did the server side code to process the data to make less work for the plugin to get decent performance for the IE 8 users. I made a class to wrap data from the new data collection objects into the legacy data holder objects. This will let the new database code be backward compatible with the legacy code until we can replace it. I found the bug reported by Jane. The software is fine. The database we use for the test site has data that is corrupted in a way it wouldn't be for production site At the end of the month I go back to each weekly *.txt file and paste all of the entries into a MS Word file for a monthly report. I give the monthly report to a liason to the contracting company who has to compile everyone's monthly reports into a single MS Word 2007 document. His problem, soon to be my problem, comes when he highlights my paragraphs like the ones above to put bullets in front of my paragraphs. When he highlights my notes to put bullets in front of them with MS Word 2007, Word rearranges the text a bit and the new line chars/carriage returns stagger the text so the text is no longer in neat chunks. This: I found the bug reported by Jane. The software is fine. The database we use for the test site has data that is corrupted in a way it wouldn't be for production site Becomes This: I found the bug reported by Jane. The software is fine. The database we use for the test site has data that is corrupted in a way it wouldn't be for production site I tried turning word wrap on in my IDE for the text files I put my status notes in. It just puts some kind of newline character in anyway. Searching/Replacing those chars in the text files has the result of destroying the paragraphs. Once my notes are pasted into MS Word, Word automatically translates them into paragraph breaks. Searching/Replacing them there has similar results. Blank lines separating the notes disappears. One big mess. What I would like is to be able to keep adding my status notes to a text file as I am now, but do something different when I paste the notes into MS Word such that my liason can select the text, hit the bulleting command and NOT have the staggered text as shown above. Any ideas? Thanks much in advance Steve

    Read the article

  • Vim: auto-comment in new line

    - by padde
    Vim automatically inserts a comment when I start a new line from a commented out line, because I have set formatoptions=tcroql. For example (cursor is *): // this is a comment* and after hitting <Enter> (insert mode) or o (normal mode) i am left with: // this is a comment // * This feature is very handy when writing long multi-line comments, but often I just want a single line comment. Now if I want to end the comment series I have several options: hit <Esc>S hit <BS> three times Both of these afford three keystrokes, taken together with the <Enter> this means four keystrokes for a new line, which I think is too much. Ideally, I would like to just hit <Enter> a second time to be left with: // this is a comment * It is important that the solution will also work with different indentation levels, i.e. int main(void) { // this is a comment* } hit <Enter> int main(void) { // this is a comment // * } hit <Enter> int main(void) { // this is a comment * } I think I have seen this feature in some text editor a few years ago but I do not recall which one it was. Is anyone aware of a solution that will do this for me in Vim? Pointers in the right direction on how to roll my own solution are also very welcome.

    Read the article

  • Is there a config value in Wine to force Enter to send CR+LF?

    - by bedwyr
    I'm pretty new to Wine and I'm trying to use an IM client which is required for my work. When I hit 'Enter' to send a chat message, the characters indicating a new line are not being correctly interpreted. Here's a basic SYN-ACK between the two of us: His view: me: SYN!him: ACK! My view: him: SYN!me: ACK!me: ACK! Is there any way I can configure Wine to handle this correctly? Please note: this is a required application and I have no way to change its configuration.

    Read the article

  • Handling extra newlines in csv files parsed with Python?

    - by rmihalyi
    I have a CSV file that contains extra newlines in some fields, e.g.: A, B, C, D, E, F 123, 456, tree , very, bla, indigo I tried the following: import csv catalog = csv.reader(open('test.csv', 'rU'), delimiter=",", dialect=csv.excel_tab) for row in catalog: print "Length: ", len(row), row and the result I got was this: Length: 6 ['A', ' B', ' C', ' D', ' E', ' F'] Length: 3 ['123', ' 456', ' tree'] Length: 4 [' ', ' very', ' bla', ' indigo'] Does anyone have any idea how I can quickly remove extraneous newlines? Thanks!

    Read the article

  • How to properly add newlines to an XML string in PHP?

    - by stormist
    I have some xml that I manually construct in a function that is something like: $xml = "<myxml>"; $xml .= "<items>"; $xml .= "<item1>blah</item1>"; $xml .= "</items>"; $xml .= "</myxml>"; When I output the string though I'd like the newlines to be present. How can I add this to the string without affecting a web service accepting the xml? Do newlines in XML even matter?

    Read the article

  • Can I suppress newlines after each template tag with Django's template engine?

    - by ento
    In Rails ERB, you can suppress newlines by adding a trailing hyphen to tags: <ul> <% for @item in @items -%> <li><%= @item %></li> <% end -%> </ul> becomes: <ul> <li>apple</li> <li>banana</li> <li>cacao</li> </ul> Is there a way to do this in Django? (Disclosure: I'm generating a csv file with Django) Edit: Clarified that the newlines I'm hunting down are the ones left behind after the template tags.

    Read the article

  • How to read back and print text with newlines from a Python (Django) string with HTML?

    - by user1801486
    If someone types in a phrase, such as: I see you driving round town with the girl I love, and I’m like: haiku. (no blank lines between each line, but the text is written on three separate lines) into a text box on a web page, and then presses a button which is then stored in a database via Django, and that string is read back and printed on a page, how can I get it to print on an HTML page with the newlines still in the text? So instead of it being printed back as: I see you driving round town with the girl I love, and I’m like: haiku. It would print as: I see you driving round town with the girl I love, and I’m like: haiku. I know that if I use: (textarea)soAndSo.body(/textarea), this preserves the newlines that were in the file when the user typed it up originally. How can I get this same effect, but without having to use textarea boxes?

    Read the article

  • how to remove spaces and newlines from server response ?

    - by Anil Namde
    When i request a page using browser / AJAX request i see lot of spaces and newlines which i think must be adding some overhead for retrieving the response as they too belong to characters means bytes and size. right ? Is there some way it can be removed while sending from the server ? how ? (I am using IIS and asp.net for development)

    Read the article

  • Vim: How to handle newlines when storing multiple commands in registers?

    - by UncleZeiv
    I have a file where I store snippets of vim commands. When I need a snippet, I yank it and then execute it with @". The snippets are stored as a script, one line per command, like this: :s/foo/bar/g :echo "hello" :s/1/2/g Edit: I removed normal mode commands from the example, as they were not part of the problem. Now this procedure doesn't work anymore: when executing the snippet, it just stops at the first line as if waiting for a newline. Is there an option somewhere affecting how @ is executed? I'm pretty sure it was working some time ago... Substituting the newline with a ^M character works but makes the file more difficult to handle. Additional information: Here's another symptom: when I yank a snippet, if I execute it with @" it stops at the first line as I just explained. But if I execute it with :@ it works. But the help file doesn't seem to imply any difference in how the two commands treat the register's content...

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8  | Next Page >