Back to Calendar Β» J...">

Delete text in line using jQuery

<td colspan="2" class="ai1ec-time"> <a class="ai1ec-button ai1ec-calendar-link" href="#"> Back to Calendar Β» </a> July 12, 2012 @ 08:00 am – July 13, 2012 @ 10:00 pm </td>​ 

Above is my HTML markup, which displays the text below.

Return to Calendar "July 12, 2012 from 08:00 to July 13, 2012 at 10:00 pm

I need to remove @ 08:00 am from the start date / time and @ 10:00 pm from the end date / time. How can this be done using jQuery? I heard and read something called Regexp, is that what you need to use? With jQuery remove ()?

I forgot to mention that the "time" is not fixed. The only thing that is fixed is that the part that needs to be deleted starts with "@" and ends with "m"

+4
source share
3 answers
 $(".ai1ec-time").html(function(i,o){ return o.replace( /@[0-9:\s]+(am|pm)/ig, '' ); }); 

Demo: http://jsbin.com/ozuwob/2/edit

+4
source

first make sure you run jQuery ( jQuery )

Then use something like this:

 $(".ai1ec-time").html(function(i,o){ return o.replace( /\@\s\d\d\:\d\d\s(am|pm)/ig, '' ); }); 

demo: js bin

+1
source
 var $td = $('td.ai1ec-time') $td.html($td.html().replace(/@ \d{1,2}:\d{2} [ap]m/g, '')) 
+1
source

Source: https://habr.com/ru/post/1410821/