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 7638105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:05:35+00:00 2026-05-31T08:05:35+00:00

<span class=WorkingHours> M,W,Th,F 7:30 AM – 4:00 PM &lt;br /&gt;Tu 7:30 AM – 6:00

  • 0
<span class="WorkingHours">
   M,W,Th,F 7:30 AM - 4:00 PM &lt;br /&gt;Tu 7:30 AM - 6:00 PM &lt;br /&gt;
</span>

will be rendered as this

M,W,Th,F 7:30 AM - 4:00 PM <br />Tu 7:30 AM - 6:00 PM <br />

Now i need to replace the &lt;br /&gt; as an empty space before it is rendered??
I already asked a similar question, but i underestimated the trickiness of this..
I did this

$('.WorkingHours').text().replace(/<br \/>/g, " ");

didn’t work..can someone help me out of this?

Shouldn’t this work?

$('.WorkingHours').text().replace(/&lt;br \&gt;/g, " "); 
  • 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-05-31T08:05:37+00:00Added an answer on May 31, 2026 at 8:05 am

    This will work:

    $('.WorkingHours').text(function(i, text) {
        return text.replace(/<br\s*\/?>/g, " "); 
    });
    

    ​
    DEMO

    In this case .html() would return the HTML entities (&lt;) whereas .text() returns the decoded characters (i.e. <). Given that,

    $('.WorkingHours').text().replace(/<br \/>/g, " ")
    

    actually works as well but you still have to assign the result back to the element.

    See also my previous answer.


    Regarding replacing the last <br /> with a different character: It might be possible with regular expressions, but in that case, I would just parse the text as HTML and perform the same operation as I showed in my previous answer:

    var $content = $('<div />').html($('.WorkingHours').text());
    $content 
     .find('br').last().replaceWith('.')
     .end().replaceWith(' ');
    
    $('.WorkingHours').html($content.html());
    

    DEMO

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

Sidebar

Related Questions

i need a regex to replace a string. <span class=\Translation\ lang=\ThisLanguage\> with this one:
I have this html right now: <h1><span class = 'highlight'><input type='image' class='removeall' src='remove.png'> <input
Let's say I do something stupid like this: <div class=my_class>fun wee!!</div> <span class=my_class><b class=my_class>Title</b></span>
Okay, so I need something like this: time_span = 1.month date = DateTime.now date
I have this markup x 3: <div class=features> <span class=overlay><img src=img/webdesign.png /></span> <h2>Web Design</h2>
I need a javascrit function that shows/hides all span tags with a specific class
The span tag currently looks like this: <span class='best_in_place<%= ' list-downvoted' if upload.downvoted? %><%=
<div class=Name> <div class=Image></div> <ul> <li><h5><span classmyName>I want this text</span></h5></li> <li class=description>The description</li> </ul>
I want to add a class to multiple span elements with common classname's based
I have a span that is generated through javascript, with its css class as

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.