[英]how to create simple regex
how to create a regex to get numbers from a block online please tell me a good regex builder如何创建正则表达式以从在线块中获取数字请告诉我一个好的正则表达式生成器
<div class="widget__header">
<div class="stat-server-title">Players online:</div>
<div class="stat-server-body"><b>2321</b></div>
</div>
<div class="right-stat-server season-stat-eng">
Not sure if this is what you want: but if you want to get the numbers from stat-server-body with a regex you can do: /<div.+class="stat-server-body"[^0-9]+([0-9]+)/
不确定这是否是您想要的:但是如果您想使用正则表达式从 stat-server-body 获取数字,您可以这样做:
/<div.+class="stat-server-body"[^0-9]+([0-9]+)/
A little breakdown:一个小故障:
I like to use https://regex101.com/ for building/testing regexes, hope this helps.我喜欢使用https://regex101.com/来构建/测试正则表达式,希望这会有所帮助。
If you want to get the number from the inner element it goes like this:如果您想从内部元素中获取数字,则如下所示:
<b>(\d+)<\/b>
which the $1 (first group) will be the number 2321 regexr.com/6p0st其中 $1(第一组)将是数字 2321 regexr.com/6p0st
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.