how to create a regex to get numbers from a block online please tell me a good regex builder
<div >
<div >Players online:</div>
<div ><b>2321</b></div>
</div>
<div >
CodePudding user response:
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. [^0-9] ([0-9] )/
A little breakdown:
- Starting with <div to match any div start.
- Then everything in between until hitting
- Then searching all non-numeric chars behind it till hitting the numbers
- And then grabbing all numbers behind it.
I like to use https://regex101.com/ for building/testing regexes, hope this helps.
CodePudding user response:
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