简体   繁体   English

使用正则表达式和Jquery操纵日期字段

[英]Using Regular Expression and Jquery to Manipulate Date Field

I'm hoping someone can help me with the targeting the date from a post 我希望有人可以帮助我确定帖子中的日期

from this "Wed, 27 Feb 2013 09:00:00 +1100" 来自这个“ 2013年2月27日,星期三09:00:00 +1100”

to this 对此

         <span class="day">27</span>
         <span class="month">Feb</span>

Ignoring the year and time. 忽略年份和时间。 The idea is that I can then style the day and month so it sits to the left of the title. 我的想法是,我可以随后设置日期和月份的样式,使其位于标题的左侧。

Class day and month can then sit inside a parent div with a darkish background like so 1 http://www.canberra.edu.au/media/test/date.jpg 这样一来,一天和一个月的课程就可以坐在具有深色背景的家长div内,例如1 http://www.canberra.edu.au/media/test/date.jpg

I'm guessing something like this? 我猜是这样的吗?

 $("h6").html(function(index, old) {
   return old.replace(some regular expression/, '<span class="day">$1</span><span class="month>$2</span>"');
 });

Thanks in advance 提前致谢

var matches = /^.{3}, (\d+) (.{3}) \d+/.exec("Wed, 27 Feb 2013 09:00:00 +1100")

// matches[1] --> "27"
// matches[2] --> "Feb" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM