1
I have a list of articles from Art. 1 to Art. 2.040., 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 numeral symbol "º";
I would like to make a regular expression that returns only the article numbers.
This is the code I used, but in some articles it generates a strange number
$str = preg_replace('/[^0-9]/', '', $novalinhas);
$artigo = $str;
But like this, it takes all the numbers from the string
I solved the question like this:
preg_match('/[0-9]+/', $novalinhas, $matches);
$artigo = implode(' ',$matches);
echo $artigo;
But I don’t know if it’s the best way.
what you have tried?
– GabrielOshiro
preg_match_all('/( d+)/', $novalinhas, $Matches); $article = implode($Matches[0]); echo "</ul>"; echo '<ul id="article' . $article . '" class="article">';
– Alê Moraes
I put a test here http://preliminarte.com.br/converter.php But in article 6 it goes wrong
– Alê Moraes
I would like to make an expression that: 1 - Capture the numbers always after the string "Art. " to the space after the number; 2 - Delete the dots and the numeral symbol "º";
– Alê Moraes
You can edit your question by adding the code and explaining more details of your problem, thereby increasing your chances of getting a quality answer.
– GabrielOshiro