Web Analytics Made Easy -
StatCounter Remove double lines - CodingForum

Announcement

Collapse
No announcement yet.

Remove double lines

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remove double lines

    I need to use RegEx to take 3 line breaks or more in a textarea and make it just two. I tried value.replace(/\n{3,}/g, '\n\n') but it did not work. Other attempts also failed.

    Can someone help me on this? It needs to be turn
    Code:
    Line 1
    
    
    
    
    
    Line 2
    Into

    Code:
    Line 1
    
    Line 2
    Thanks for you help!
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Code:
    value.replace(/\n{2,}/gm, '\n\n')
    Normally a regular expression will only match inside a single line of text within the string.

    You have to tell the regular expression to span multiple lines of text within the string.

    use the pattern flag "m" for multi line mode.

    Comment

    Working...
    X