Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7707891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:28:25+00:00 2026-06-01T00:28:25+00:00

On a messaging system, line breaks have been added automatically when messages are posted

  • 0

On a messaging system, line breaks have been added automatically when messages are posted after a certain number of characters (silly way to do things but unfortunately that isn’t allowed to be changed). This means that breaks have been automatically inserted into URLs, so that long ones are split up, eg:

http://www.stackoverflow.com/some-more-<br/>stuff

When messages are retrieved, a function converts links into tags, which for this URL results in:

<a href='http//www.stackoverflow.com/some-more-'>http://www.stackoverflow.com/some-more-</a>stuff

I need to remove the <br/> before it’s turned into a link.

I have had the message split into words on spaces, then iterated through each word, seeing if it contains ‘http://&#8217; or ‘www.’ and then replacing <br/> with an empty string if it does.

However, this only works on URLs entered in a paragraph, for example:

The URL is http://www.stackoverflow.com

It doesn’t work for URLs entered with line breaks around it, for example:

Here’s the URL:

http://www.stackoverflow.com

And here’s some more text

..is chopped into:

Here’s the URL:http://www.stackoverflow.comAnd here’s some more text

..because all the line breaks have been removed in this ‘word’ (as I’m splitting on spaces, all of that is seen as one word).

I thought I could split on line breaks, but then this won’t work for URLs entered in a paragraph as in the first example, and it will also split in the middle of any URLs that contain a break.

Clearly I need to somehow just find URLs and replace line breaks inside them, but I’m having real trouble with this, as I just can’t seem to do it!

If I’ve left out any details feel free to ask and I’ll get back at once. Thanks 🙂

PS – This is being coded in C#.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:28:26+00:00Added an answer on June 1, 2026 at 12:28 am

    Please delete the other answer.

    I wasn’t able to understan your problem. No I think I do.

    You can use this regex to find all the urls, wheter they are broken in several lines or not:

    (?<url>https?://(.|\r\n)*?(=? ))
    

    This will return capture groups called “url” which contain your url, with or without line breaks inside them. You get this with the (.|\r\n)*, which allows to find urls broken in several lines by \r\n (cr, lf). Check if this is the end of line coding of your messages. If not, you can change the grouo with (.|\n) or whatever is your case.

    Oce you’ve found your urls, you can remove the \r\n inside them.

    You can improve it using this regex:

    (?<url>https?://(.|(?<deleteMe>\r\n))*?(=? ))
    

    The deleteMe group captures all the offending line breaks inside the urls, so you can safely remove them all.

    Important: You have to run the regex with multiline option If not, it will not work.

    Sample text:

    The firs url is http://www.casa.com/aqui.htm and the second is http://www.the
    house.com/broken url
    

    Matches:

    url: http://www.casa.com/aqui.htm
    url: http://www.the\r\nhouse.com/broken
    

    Delete me group matches the bold \r\n

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have make a messaging system in which user can send messages to each
I have been working on having a instant messaging system on a website(kind of
Suppose you have a messaging system built in PHP with a MySQL database backend,
I am coding a messaging system and I don't want to have short IDs
I have a basic messaging system set up and I m using the same
I have a micropost/messaging system and each time a new micropost or comment/message is
I am creating a simple messaging system in WCF and have implemented a minimal
I have a simple messaging system, and I'd like to display both Received and
I have a simple messaging system on my site. I would like to implement
I'm building a small messaging system like you have in facebook. Only thing is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.