The same number of characters in two parts of the regular expression
To begin with, I am using PHP and preg_replace
I created some regex /(={2,6})\W+(={2,6})/
to try and match
Lorem Lorem Lorem Lorem Lorem ==Etymology== ==Links== Lorem Lorem Lorem Lorem Lorem
( http://pastebin.com/5kAKQM1x )
so I can turn it into
Lorem Lorem Lorem Lorem Lorem ==Etymology== <<My Insert Here>> ==Links== Lorem Lorem Lorem Lorem Lorem
( http://pastebin.com/aamRSXU4 )
The problem is that my regex also matches
Ussher believed the whole creation process occurred on that day. ==Religious views== ===Jewish traditions=== In rabbinic writings and the
( http://pastebin.com/HJ2Vy7Md )
How can I ensure that both sides have the same number of characters =
? How to use {2,6}
in different ways.
+3
mr.user1065741
source
to share
2 answers
Use backlink
/(={2,6})\W+\1/
+3
abc667
source
to share
use a backlink to the previous capture
(={2,6})(\S+)(\1)
(I assume you mean \ S +, not \ W +) ...
+1
Vorsprung
source
to share