PHP preg匹配所有(PHP preg match all)
$str = <a href="keep.php?casuser=400000018623110" onclick="ajaxLinkSend('globalContainer', 'keep.php?casuser=400000018623110'); return false;" style="color:#ffca3e">
我的工作preg匹配所有:
preg_match_all('/\'keep.php\?casuser=(.*) style=\"color:#ffca3e/iU', $result, $matches2); $matches2[1][0] = 400000018623110'); return false;"
但我只想要数字
没有结果:
preg_match_all('/\'keep.php\?casuser=(.*)\'\); return false;" style=\"color:#ffca3e/iU', $result, $matches2);
任何人都可以帮助我吗? 并解释我为什么不工作? 谢谢
$str = <a href="keep.php?casuser=400000018623110" onclick="ajaxLinkSend('globalContainer', 'keep.php?casuser=400000018623110'); return false;" style="color:#ffca3e">
My working preg match all:
preg_match_all('/\'keep.php\?casuser=(.*) style=\"color:#ffca3e/iU', $result, $matches2); $matches2[1][0] = 400000018623110'); return false;"
But I want only the numbers
No result with:
preg_match_all('/\'keep.php\?casuser=(.*)\'\); return false;" style=\"color:#ffca3e/iU', $result, $matches2);
Can anyone help me with that? And explain me why its not working? thx
原文:https://stackoverflow.com/questions/19809102
更新时间:2022-07-24 10:07
最满意答案
我相信
MM
是月份的数字格式,即当月10月(10)。 尝试将其更改为mm
如下面的代码。moment(testDate, ["h:mm"]).format("H:mm");
I believe
MM
is numeric format for month which is current month October (10). Try to change it tomm
like following code.moment(testDate, ["h:mm"]).format("H:mm");
相关问答
更多-
终于完成了 GROUP BY DATEPART(YEAR, DT.[Date]), DATEPART(MONTH, DT.[Date]), DATEPART(DAY, DT.[Date]), DATEPART(HOUR, DT.[Date]), (DATEPART(MINUTE, DT.[Date]) / 10) finally done with GROUP BY DATEPART(YEAR, DT.[Date]), DATEPART(MONTH, DT.[Date]), DATEPART(DAY, D ...
-
@Rayjax解决方案在最新版本的moment.js中不再有效。 moment.localeData().longDateFormat()行为已更改。 LT现在已经被时间格式所取代。 而不是dddd, MMMM D, YYYY LT它现在返回dddd, MMMM D, YYYY h:mm A 因此,从字符串中删除LT不再起作用。 但我们可以删除当前语言环境的已编译LT : moment.localeData().longDateFormat('LLLL') .replace( moment.locale ...
-
这应该得到你想要的: moment().format("H[h] mm[m]"); 从momement.js文档中查看Format 。 []用于转义格式字符串中的字符。 This should get what you're after: moment().format("H[h] mm[m]"); Take a look at Format from the momement.js docs. The [] is used to escape characters in format strings. ...
-
与时区的MomentJS问题(MomentJS issue with timezone)[2023-05-29]
当您使用时,除非您正在处理第三方API,否则通常无需调用.toDate() 。 在你的情况下,我相信你想要的只是将你的日期从本地转换为UTC。 你几乎就在那里,但你需要清理一些东西。 您的结果代码应该是: var date ="05/30/2016"; var time ="10:00"; moment(date+ " " + time, 'MM/DD/YYYY HH:mm').utc().format() "2016-05-30T15:00:00Z" 有关此代码的一些注意事项: 我现在的时区是UT ... -
你可以除以60,得到几个小时,并在几分钟内做模数 var totalTimeInMin = 2273; console.log(Math.floor(totalTimeInMin / 60) + ':' + totalTimeInMin % 60) You can just divide by 60 , to get hours and do modulus for minutes var totalTimeInMin = 2273; console.log(Math.floor(totalTimeIn ...
-
只需计算循环内所有持续时间的总和,然后在循环外部输出结果。 开始时间为0 ms( moment.duration(0) ),然后使用add添加计算的差异。 在循环外打印结果。 你的代码可能如下所示: // Create a duration of 0 ms var tot = moment.duration(0); for (i = 0; i < trueresultgroup.length; i++) { var on = (trueresultgroup[i]). ...
-
Momentjs日期验证(Momentjs date validation)[2022-07-07]
您可以使用本机Date构造函数来处理溢出: var date = moment(new Date(2014,2,17,9,60)); You may use the native Date constructor to deal with overflows for you : var date = moment(new Date(2014,2,17,9,60)); -
MomentJs。(MomentJs. When time is converted why does it always output the hour with :10 as minutes?)[2022-06-07]
我相信MM是月份的数字格式,即当月10月(10)。 尝试将其更改为mm如下面的代码。 moment(testDate, ["h:mm"]).format("H:mm"); I believe MM is numeric format for month which is current month October (10). Try to change it to mm like following code. moment(testDate, ["h:mm"]).format("H:mm"); -
你没有用正确的方式。 首先,要使用不是ISO 8601格式的字符串创建一个时刻对象,请使用moment(String, String); 或者如果您的输入是一个数字,您可以使用moment({unit: value, ...}); 指定单位(如hours )。 然后不要比较字符串,但你应该使用像isBefore这样的isBefore 。 您的代码的另一个问题是, moment(dayTime2).add(15, 'minute')会创建一个新的时刻对象,但您需要修改dayTime2本身。 请改用dayTim ...
-
使用AngularJS和MomentJS的日期操作问题/问题(Date manipulation issues/questions using AngularJS and MomentJS)[2022-07-17]
我想也许Moment的语法有些偏差。 尝试这样的事情: var beginDate = moment($ scope.task.BeginDate.toString())。format(“MM / DD / YYYY”); I think perhaps the Moment syntax is off a bit. Try something like this: var beginDate = moment($scope.task.BeginDate.toString()).format("MM/DD/ ...