I have a list of articles from Art. 1 through Art. 2040, but in each article there are other numbers.
I would like to make an expression that: 1 - Capture the numbers always after the string "Art." Until the space after the number; 2 - Exclude the points and the symbol "º";
I would like to make a regular expression that would return only the article numbers.
This is the code I used, however, in some articles it generates a strange number
$str = preg_replace('/[^0-9]/', '', $novalinhas);
$artigo = $str;
But so, it takes all the numbers in the string
I solved the question like this:
preg_match('/[0-9]+/', $novalinhas, $matches);
$artigo = implode(' ',$matches);
echo $artigo;
But I do not know if it's the best way.