2
I would like to do a regex to apply a class to each row with Roman numbers, the regex would be? /(<li>\s*<p>$romanos\)_\-_/
?
The documents are like this:
<li>
<p>I - blablabla</p>
</li>
<li>
<p>II - blablabla</p>
</li>
<li>
<p>III - blablabla</p>
</li>
I’d like to keep it that way
<li class="inciso">
<p>I - blablabla</p>
</li>
<li class="inciso">
<p>II - blablabla</p>
</li>
<li class="inciso">
<p>III - blablabla</p>
</li>
I created an array of Roman numbers
$romanos = array(I,II,III,IV,V,VI,VII,VIII,IX,X,XI,XII,XIII,XIV,XV,XVI,XVII,XVIII,XIX,XX,XXI,XXII,XXIII,XXIV,XXV,XXVI,XXVII,XXVIII,XXIX,XXX,XXXI,XXXII,XXXIII,XXXIV,XXXV,XXXVI,XXXVII,XXXVIII,XXXIX);
Here are the text variables I’m looking for
$semClassInciso = '/ <li>
<p>$romanos - /';
Here is the text variable with the LI tag whose class is "inciso
$comClassInciso = '/ <li class="inciso">
<p>$romanos - /';
Here is the document where the text with the initials
$documento = file_get_contents($arquivo);
$documento1 = preg_replace($semClassInciso, $comClassInciso , $documento);
echo $documento1;
In short, I want to add the tag <li class="inciso">
in all occurrences of Roman numerals at the beginning of a paragraph.
I couldn’t understand, you can explain better what you want?
– stderr
In the variable $semClassInciso, what varies is the number, I have section 1, 2, 3, 4 .... and I would like to add the initial class in all occurrences
– Alê Moraes
But the numbers are in Roman
– Alê Moraes
Section I, II, III
– Alê Moraes
The title doesn’t match what you want, but from what I understand, try something like this: http://ideone.com/zUZRCL
– stderr
I edited the question, see if it was clearer, a little, but still do not know how to make more clear the title
– Alê Moraes
See if this is something you want to do: http://ideone.com/7eDrPr
– stderr
the explanation was confused to understand. I edited an excerpt and added a summary that explains what you want.
– Daniel Omine
@qmechanik, put which lines I have in the file, this is the structure, the script should read each line and apply the class inciso in each line
– Alê Moraes
@Try it this way: http://ideone.com/0gZclc, see if it works in your case.
– stderr