Home > Back-end >  how to create simple regex
how to create simple regex

Time:07-04

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:

  1. Starting with <div to match any div start.
  2. Then everything in between until hitting
  3. Then searching all non-numeric chars behind it till hitting the numbers
  4. 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

  • Related