Search Results

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

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

  • Using regular expression to trim html

    - by Tim
    Been trying to solve this for a while now. I need a regex to strip the newlines, tabs and spaces between the html tags demonstrated in the example below: Source: <html> <head> <title> Some title </title> </head> </html> Wanted result: <html><head><title>Some title</title></head></html> The trimming of the whitespaces before the "Some title" is optional. I'd be grateful for any help

    Read the article

  • Javascript handling textarea

    - by bbenton
    Hi all, I'm a bit new to Javascript and am trying to create a delimited string from a textare. The problem is when passing in the textarea, it adds newlines for each row on the textarea. I need to have the entire textarea parsed into a string with a delimiter for each line (replacing the newline char). So for example, if you passed in a textarea with the following lines (which is also how it looks when using the alert function): abcd efgh ijkl It would look like: abcd-efgh-ijkl after parsing. function submitToForm(form) { var param_textarea = form.listofplugins.value; var test = param_textarea.replace(/\\r?\\n/, /:/) alert(test); } Thanks a lot!

    Read the article

  • What's wrong with my markdown syntax? Broken in stackoverflow and bluecloth...

    - by nfm
    I just wrote some markdown and it doesn't seem to render correctly. Is it legal syntax to have an ordered list, followed by newlines, then followed by an unordered list? Or is this a bug in bluecloth? For example: 1. One 2. Two 3. Three * Apple * Banana * Carrot Bluecloth creates a single <ul> and nests apple, banana and carrot as <li>'s under it. Stackoverflow's post editor (wmd?) does this too. Am I just doing it wrong? Surely this is a common usage case...

    Read the article

  • Excel XML Newline in Cell

    - by spasarto
    I am using LINQ to XML to create an Excel XML file. I want to include newlines within the cells. Excel uses the &#10; literal to represent a new line. If I try to add this using an XText: XText newlineElement = new XText( "Foo&#10;Bar" ); I get: Foo&amp;#10;Bar Which shows up in Excel as: Foo&#10;Bar Is there a way to write &#10 to the XML file without doing a String.Replace( "&amp;#10;", "&#10;" ) over the resulting file text?

    Read the article

  • Why, in Ruby, does Array("foo\nbar") == ["foo\n", "bar"]?

    - by Tyson
    In Ruby 1.8.7, Array("hello\nhello") gives you ["hello\n", "hello"]. This does two things that I don't expect: It splits the string on newlines. I'd expect it simply to give me an array with the string I pass in as its single element without modifying the data I pass in. Even if you accept that it's reasonable to split a string when passing it to Array, why does it retain the newline character when "foo\nbar".split does not? Additionally: >> Array.[] "foo\nbar" => ["foo\nbar"] >> Array.[] *"foo\nbar" => ["foo\n", "bar"]

    Read the article

  • Emacs with CEDET changes copy/paste to include trailing spaces?

    - by Paul D.
    I just started trying out CEDET today, which I really like, but it seems to do something completely worthless with respect to copying/pasting. If I highlight some stuff and copy it, when it gets pasted back the newlines are eliminated and there is just a ton of trailing whitespace on each line. This is really worthless. All I have in my .emacs right now for CEDET is the following: (load-file "~/.emacs.d/cedet-1.0pre7/common/cedet.el") (require 'semantic-ia) (require 'semantic-gcc) (semantic-load-enable-code-helpers) Does anybody know how to turn this off? I can't find anything about this except that the CEDET main page says it has "magic copy & paste".

    Read the article

  • replace <br> to new line between pre tag

    - by saturngod
    I want to convert <p>Code is following</p> <pre> &lt;html&gt;<br>&lt;/html&gt; </pre> to <p>Code is following</p> <pre> &lt;html&gt; &lt;/html&gt; </pre> I don't know how to write regular expression for replace between pre tag in PHP. I tried this code http://stackoverflow.com/questions/1517102/replace-newlines-with-br-tags-but-only-inside-pre-tags but it's not working for me.

    Read the article

  • Inserting a newline into a pre tag (IE, Javascript)

    - by Itay
    In IE when I insert text into a <pre> tag the newlines are ignored: <pre id="putItHere"></pre> <script> function putText() { document.getElementById("putItHere").innerHTML = "first line\nsecond line"; } </script> Using \r\n instead of a plain \n does not work. <br/> does work but inserts an extra blank line in FF, which is not acceptable for my purposes.

    Read the article

  • newline in Rackspace Cron Job email

    - by senloe
    I'm running backups against multiple databases hosted at Rackspace. This is working fine. The problem I'm running into is with the results email. I'm using Response.Write to write a message to the web page which is used for logging and is also consumed by the results mail sent out by the job. The problem is I can't seem to get newlines to appear between log messages. The logfile stored on the server is correct, but only the first newline shows up in the email. The mail is in Plain Text format so I tried using "\n" and System.Environment.Newline and neither work. I also tried using <br/> with no luck. Does anybody have any ideas?

    Read the article

  • jQuery .next() and .prev() not working as they should!

    - by Luca Matteis
    I want to get the .next() and .prev() sibling of an HTML element without excluding TextNodes. I basically need to understand if an element is directly sorrounded by <br> HTML elements. This would return true: <br> <div></div> <br> This would return false: <br> Some text <div></div> <br> BUT this needs to also return true: <br> <div></div> <br> The third example basically uses an empty TextNode, or blankspaces, or newlines. What's the best way to do this?

    Read the article

  • making a programming language

    - by None
    I was wondering which way would create a faster programming language, because I have tried both. Writing code that takes the text, splits it by whitespace or newlines or something, then processes each line and has a dictionary for variables. Or writing code that takes text and converts it to another programming language. This is an example of how a very simple version of the first way would be programmed in python: def run(code): text = code.split(";") for t in text: if t == "hello": print "hi" second: def run(code): rcode = "" text = code.split(";") for t in text: if t == "hello": rcode += "print 'hi'"

    Read the article

  • Line breaks in XML are ignored by the SAX Parser

    - by Siddharth Iyer
    I am parsing an XML with some CData that contains line breaks. The parser ignores these line breaks. I am trying to figure out a way to catch these newlines in the characters() method and replace them with a break tag for display purposes. I have tried almost everything under the sun and have been scouring stackoverflow for the past 3 hours. I tried every combination of replacing "\n", "\r\n" and so on with a break tag in the characters() method of the parser. I am absolutely helpless right about now.... and would sincerely appreciate any help I can get. Thanks!!!

    Read the article

  • Vim: replacing start and end of a visual char, line or block

    - by gattu marrudu
    I am trying to find a shortcut to place a custom comment sequence on my code, e.g.: /* start of comment blah end of comment /**/ (it is easier to void the comment by just adding a / to the beginning) I would like to do this in Vim by selecting a visual line, block or char and adding '/' characters at the beginning of the block and '/*/' at the end, plus newlines. After selecting some lines (Shift-V) I tried this: '<,'>s/\(.*\)/\/*\r\1\r\/**\// But it adds the comment chars at EACH newline. How can I only apply the substitution at the beginning and end of the selected range? Thanks gm

    Read the article

  • Firefox DOMParser problem

    - by Michael
    For some reason DOMParser is adding some additional #text elements for each newline \n for this url http://rt.com/Root.rss ...as well as many other RSS I've tried. I checked cnn/bbc feeds, they don't have newlines and dom parser handling them nicely. So I have to add the following before parsing it var xmlText = htmlText.replace(/\n[ ]*/g, ""); var xmlDoc = parser.parseFromString(xmlText, "text/xml"); Server is returning text/xml. var channel = xmlDoc.documentElement.childNodes[0]; this returning \n without my code above and channel with correction.

    Read the article

  • Remove newline character while XML parsing

    - by Prashant
    Hi, I am facing a problem while XML parsing. I have an NSMutablestring currentElementValue that has newlines into it. It has been received as an XMl from a web source. Even when i am trying to remove newline charactersets of substring the first 3 char there is no effect on the string. What can be done here? Regards PC Code is (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(!currentElementValue) currentElementValue = [[NSMutableString alloc] initWithString:string]; else { [currentElementValue substringFromIndex:3]; [currentElementValue stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; NSLog(@"Processing Value : %@ with length %d", currentElementValue,[currentElementValue length] ); }

    Read the article

  • Creating readable html with django templates

    - by rileymat
    When using Django for html templating how do I create good html markup formatting. I am trying to make use of content blocks. But the content blocks show up at different levels of indentation in different templates. How do I get the content blocks to show indented like it would be if someone was to hand write the html. I am having the same problem with newlines; I can smash all the blocks together in the template. At that point the html looks better, but the templates are unmaintainable. I guess the question is how to you create pretty html markup with the django templating system?

    Read the article

  • Safe ASCII char to replace whitespace before storing

    - by AngryWhenHungry
    My code passes a big bunch of text data to a legacy lib, which is responsible for storing it. However, it tends to remove trailing whitespace. This is a problem when I read the data back. Since I cannot change the legacy code, I thought about replacing the all spaces with some uncommon ASCII character. When I read back the text, I can replace them back. Is this a bad idea, considering that I cannot touch the legacy storage code? Which character can I use as a substitute? I was considering some char upwards of 180. There will only be spaces - no tabs or newlines - in the data. The data is alphanumeric, with special characters.

    Read the article

  • What is a better way to write this regular expression?

    - by rxgx
    I am converting XML children into the element parameters and have a dirty regex script I used in Textmate. I know that dot (.) doesn't search for newlines, so this is how I got it to resolve. Search language="(.*)" (.*)<education>(.*)(\n)?(.*)?(\n)?(.*)?(\n)?(.*)?</education> (.*)<years>(.*)</years> (.*)<grade>(.*)</grade> Replace grade="$13" language="$1" years="$11"> <education>$3$4$5$6$7$8$9</education> I know there's a better way to do this. Please help me build my regex skills further.

    Read the article

  • Having trouble getting GET variables from url.

    - by mchl
    Hey everyone, I'm having trouble with this algorithm to extract the get variables from a url and print them each on a new line like: x=y z=hello etc. but instead it prints a seemingly random section of the url with no newlines to the file. There must be a logic error of some kind but i just can't spot it. for(i_m=0;i_m<len_m;i_m++) { if(var_m[i_m]=='&') { fwrite(var_m+offset_m, 1, amp_m, echo_out); fputc('\n',echo_out); offset_m+=amp_m; amp_m=0; } amp_m++; } any help appreciated.

    Read the article

  • Extra line breaks inserted in MrEd text%

    - by Jesse Millikan
    In a DrScheme project, I'm using a MrEd editor-canvas% with text% and inserting a string from a literal in a Scheme file. This results in an extra blank line in the editor for each line of text I'm trying to insert. Is this a Windows vs. Unix linebreak problem? I can't find anything about text% treats line breaks in the documentation. ; Inside a class definition: (define/public (edit-pattern p j b d h) (send input-beat set-value (number->string b)) (send input-dwell set-value (number->string d)) (send hold-beats set-value (number->string h)) (send juggler-t erase) ; Why do these add extra newlines (send juggler-t insert j) (send pattern-t erase) (send pattern-t insert p)) (define juggler-ec (new editor-canvas% [parent this] [line-count 12])) (define juggler-t (new text%)) (send juggler-ec set-editor juggler-t) (define pattern-ec (new editor-canvas% [parent this] [line-count 20])) (define pattern-t (new text%)) (send pattern-ec set-editor pattern-t) ; Lots of other stuff...

    Read the article

  • atkbd.c spamming the logs. How to get rid? what is this?

    - by turbo
    On my Vostro 1000 notebook the following messages spam my dmesg: [18678.728936] atkbd.c: Unknown key released (translated set 2, code 0x8d on isa0060/serio0). [18678.728941] atkbd.c: Use 'setkeycodes e00d <keycode>' to make it known. [18679.831109] atkbd.c: Unknown key pressed (translated set 2, code 0x8d on isa0060/serio0). [18679.831119] atkbd.c: Use 'setkeycodes e00d <keycode>' to make it known. [18679.841607] atkbd.c: Unknown key released (translated set 2, code 0x8d on isa0060/serio0). [18679.841615] atkbd.c: Use 'setkeycodes e00d <keycode>' to make it known. [18680.901733] atkbd.c: Unknown key pressed (translated set 2, code 0x8d on isa0060/serio0). [18680.901744] atkbd.c: Use 'setkeycodes e00d <keycode>' to make it known. [18680.911536] atkbd.c: Unknown key released (translated set 2, code 0x8d on isa0060/serio0). [18680.911546] atkbd.c: Use 'setkeycodes e00d <keycode>' to make it known. It's most probably not from an actual key because it appears in regular intervals. First what is it? It could be my battery since it's nearly dead, as in loadable to 11 % of the initial capacity, but I have no evidence for that. What is this / how can I find out where this comes from? How can I get rid of it? Is there a 'dud' keycode? When I assign a keycode with sudo setkeycode e00d $(random keycode) the key does actually get pressed. That makes it impossible to enter sudo password for example. So any 'real' keycode is not an option. It hasn't been like that half a year ago. Even better than the dud keycode would be a real fix. It happens from 10.04 to 12.04 (before that I don't know). I did read zcat /usr/share/doc/udev/README.keymap.txt.gz |less as suggested in the Ubuntu Wiki. /lib/udev/findkeyboards && sudo /lib/udev/keymap -i input/event5 produces what appears to be newlines in rapid succession. sudo udevadm monitor doesn't show the event.

    Read the article

  • What algorithms can I use to detect if articles or posts are duplicates?

    - by michael
    I'm trying to detect if an article or forum post is a duplicate entry within the database. I've given this some thought, coming to the conclusion that someone who duplicate content will do so using one of the three (in descending difficult to detect): simple copy paste the whole text copy and paste parts of text merging it with their own copy an article from an external site and masquerade as their own Prepping Text For Analysis Basically any anomalies; the goal is to make the text as "pure" as possible. For more accurate results, the text is "standardized" by: Stripping duplicate white spaces and trimming leading and trailing. Newlines are standardized to \n. HTML tags are removed. Using a RegEx called Daring Fireball URLs are stripped. I use BB code in my application so that goes to. (ä)ccented and foreign (besides Enlgish) are converted to their non foreign form. I store information about each article in (1) statistics table and in (2) keywords table. (1) Statistics Table The following statistics are stored about the textual content (much like this post) text length letter count word count sentence count average words per sentence automated readability index gunning fog score For European languages Coleman-Liau and Automated Readability Index should be used as they do not use syllable counting, so should produce a reasonably accurate score. (2) Keywords Table The keywords are generated by excluding a huge list of stop words (common words), e.g., 'the', 'a', 'of', 'to', etc, etc. Sample Data text_length, 3963 letter_count, 3052 word_count, 684 sentence_count, 33 word_per_sentence, 21 gunning_fog, 11.5 auto_read_index, 9.9 keyword 1, killed keyword 2, officers keyword 3, police It should be noted that once an article gets updated all of the above statistics are regenerated and could be completely different values. How could I use the above information to detect if an article that's being published for the first time, is already existing within the database? I'm aware anything I'll design will not be perfect, the biggest risk being (1) Content that is not a duplicate will be flagged as duplicate (2) The system allows the duplicate content through. So the algorithm should generate a risk assessment number from 0 being no duplicate risk 5 being possible duplicate and 10 being duplicate. Anything above 5 then there's a good possibility that the content is duplicate. In this case the content could be flagged and linked to the article's that are possible duplicates and a human could decide whether to delete or allow. As I said before I'm storing keywords for the whole article, however I wonder if I could do the same on paragraph basis; this would also mean further separating my data in the DB but it would also make it easier for detecting (2) in my initial post. I'm thinking weighted average between the statistics, but in what order and what would be the consequences...

    Read the article

  • My co-worker has not been doing such a good job for the past decade. What do I do? [closed]

    - by stijn
    Possible Duplicate: How do I approach a coworker about his or her code quality? I started working with him almost a decade ago and back then I had never really programmed before, being a young hardware engineer. Right now however I have made quite some progress in all areas being part of software design and i am much, much more skilled than my co-worker who is 15 years older and has been programming more than twice as long. He is super nice and definitely smart enough, but lately his lack of skill and performance are starting to drag me down because we're more and more working on the same codebase. And soon we are going to do a quite ambitious start from scratch creating a whole new hard/software system. I feel it is time to address all issues now, but i do not know how to start. Here are some of the things that I would like to see him improve on: no consistent usage of style, spaces nor tabs (eg if(something ) a =b ) adds newlines around pieces of code to make it easier to read, then commits those with messages like 'no changes made' overall commit messages are useless and so are most of the comments, if there are any (eg 'remove solves for bug Rik' if Rik reported a bug). There is no function/class documentation. lots of spelling errors, in both English and native language, which sometimes are mixed 6/7/8 level deep deep nesting is no exception, a lot of functions start with one level already like if(ptr!=Null){ even when ptr is the result of allocation via new in the constructor numerous source files have over 10k lines of those lines, a major part is simply a result of copy-pasting functionality instead of using a function. This includes copying comments so we end up with 50 occurrences of var=NULL; //TODO TEST this!!!!!!! another part is hundreds of lines of dead code knows what versioning does, yet comments out old code and places new code underneath it when making changes coding skills are below par, especially for the type of rather high precision applications we do. Yet somehow, after a lot of trying and testing, stuff starts to work. But then breaks again some time later because every change casues a waterfall effect. violates every single item in the C++ FAQ lite, practices every bad practice I can think of still doesn't know how to properly use the debugger, but spends hours inspecting messy logfiles in notepad on a tiny laptop screen. Does not make any adjustments to the settings of the software he uses. Never uses keyboard shortcuts. does not seem to progress or learn new things at all. Work rather slow, mostly due to the lack of planning and incorrect usage of tools. How does one deal with this? For starters, how do I make him aware of all these problems? Should I tell the staff about it? And the next step, how to get him to learn new things and adopt another way of working?

    Read the article

  • Unconvert Text File from Binary Format

    - by Hammer Bro.
    I've got a rather large CSV file (~700MB) which I know to consist of lines of 27-character alpha-numeric hashes; no commas or anything fancy. Somehow, during its migration from Windows to Linux (via winSCP and then a few regular SCPs), it has converted into some kind of binary format I am unfamiliar with. If I open the file in vi, everything appears fine, and it says [converted] at the bottom, although I know it's not a line endings issue (and dos2unix doesn't help). If I 'head' the file, it looks proper except for a "ÿþ" at the beginning of the first line. If I open up the file in nano, however, I see the "ÿþ" at the start and then "^@" before every character (even newlines and EoF). If I try to re-save or copy the file (say via: head file.csv short.txt), this special encoding is preserved. I copied the first ten lines out of vi (which displays it properly) into my Windows clipboard via my SSH client, then pasted it into a new text file, test.txt. This file is visually identical when opened in vi (and similar through 'head', minus the "ÿþ"), although it's roughly half of the filesize. Additionally, file test.txt test.txt: ASCII text file short.txt short.txt: I have no idea what format this once-text file got converted to (it's notoriously hard to search the internet for symbols), but surely there must be some way to convert it back. Any ideas?

    Read the article

  • Discover intended Foreign Keys from JOINS in scripts

    - by Jason
    I'm inheriting a database that has 400 tables and only 150 foreign key constraints registered. Knowing what I do about the application and looking at the table columns, it's easy to say that there ought to be a lot more. I'm afraid that the current application software will break if I started adding the missing FKs because the developers have probably come to rely on this "freedom", but step one in fixing the problem is to come up with the list of missing FKs so we can evaluate them as a team. To make matters worse, the referencing columns don't share a naming convention. The relationships ARE coded informally into the hundreds of ad-hoc queries and stored procedures, so my hope is to parse these files programmatically looking for JOINS between actual tables (but not table variables, etc). Challenges I foresee in this approach are: newlines, optional aliases and table hints, alias resolution. Any better ideas? (Besides quitting) Are there any pre-built tools that can solve this? I don't think regex can handle this. Do you disagree? SQL Parsers? I tried using Microsoft.SqlServer.Management.SqlParser.Parser but all that is exposed is the lexer - can't get an AST out of it - all that stuff is internal.

    Read the article

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