Page 6 of 6 FirstFirst ... 456
Results 51 to 57 of 57

Thread: How to restore broken lines in links in my PHP editor?

  1. #51
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    it has to be in javascript, but if you post your php idea, I could use it too for the php part of my editor.

  2. #52
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    I already did, but here it is again. The only difference is that I removed the s modifier:

    Code:
    <?php
    $text="<img src=\"http://qwikad.com/images/logo.png\" 
    
    alt=\"something\"
    
    title=\"something\">this
    is
    
    fine
    <img src=\"http://qwikad.com/images/logo.png\" 
    
    alt=\"something\"
    
    title=\"something\">";
    $text=preg_replace('/(\r\n){1,}(?=((?!<)[\s\S])*>)/','',$text);
    echo "$text";
    ?>
    Could you post the complete javascript that you have so that I have something to work with?
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #53
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    Ok, got it. Will test it over the next couple days.

  4. #54
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by qwikad.com View Post
    I was thinking how many broken lines can an average HTML banner ad possibly have and still be a valid code, and I came up with 8:
    Code:
    <
    img 
    src="http://something.com/images/something.png" 
    title="something" 
    alt="something" 
    width="300" 
    height="250" 
    border="0"
    >
    So if that var regex could be adjusted to restoring 8 broken lines, I think it will cover every possible inconsistency of any HTML banner ad (and more).
    What about
    Code:
    <
    img 
    src
    =
    "http://something.com/images/something.png" 
    title
    =
    "some
    thing" 
    alt
    =
    "something" 
    width
    =
    "300" 
    height
    =
    "250" 
    border
    =
    "0"
    >
    ? That's still perfectly valid HTML (and creates the same DOM as your example).

    **********

    Have you looked at the links james provided? They're good references. You can experiment with the fiddle.

  5. #55
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    So, it can have up to 16 new lines... Which is possible. I saw HTML codes formed so poorly, from all the copying and pasting, that I am not even sure WHY they work.

    You mean the link to the php site? I am not sure if I can make sense of what's going on there.

  6. #56
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    He also linked to regular-expressions.info. But take a look anyway, it can be daunting to get into, but it's not "impossible."

    As for newlines, the number is almost unlimited. You can have newlines almost anywhere in HTML and they don't break anything (they're considered whitespace).

  7. #57
    Join Date
    Oct 2012
    Posts
    180
    Thanks
    22
    Thanked 1 Time in 1 Post

    Default

    You know I think I can live with what I've got. If once or twice a month someone posts something that doesn't show, it's not going to negatively impact our service as a whole. People would have to make sure that their HTML ads are formed right... if they want to see them on our site.

Similar Threads

  1. How to create a broken links checker from scratch
    By SR123 in forum Looking for such a script or service
    Replies: 0
    Last Post: 06-03-2009, 03:03 PM
  2. Restore slide position!!!
    By shlajfka in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 11-25-2008, 01:04 PM
  3. links at the center appear broken
    By leonidassavvides in forum HTML
    Replies: 1
    Last Post: 04-23-2008, 02:49 PM
  4. Program to check broken links?
    By Freeman in forum The lounge
    Replies: 6
    Last Post: 08-24-2007, 04:04 PM
  5. Code Restore... (need help)
    By Harlem Of Nem in forum JavaScript
    Replies: 5
    Last Post: 08-06-2007, 08:03 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •