0

I am using mediawiki and I have the text
<div class="list-block"> == 2014 and beyond == <div id="list">My best day </div></div> I'm using the regular expresion:

%<div class="list-block"[^>]*>\n?<h2>(.+)</h2>\n?(<div id="list">)?(.*)(</div>)?\n?</div>\n</div>%sU

and it isn't working. It originally had <div class="list-block">''' 2014 and beyond'''<div id="list">My best day </div></div> and the %<div class="list-block"[^>]*>\n?<b>(.+)</b>\n?(<div id="list">)?(.*)(</div>)?\n?</div>\n</div>%sU which worked great. I switched the <b> with the <h2> and now it isn't working. Any idea what I am doing wrong? (I don't mind removing the <h2> tags altogether but that doesn't work either).

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
LTech
  • 1,677
  • 5
  • 29
  • 48
  • Are you parsing the wikitext to HTML before applying the regular expression? – Bergi Sep 11 '13 at 10:42
  • “Any idea what I am doing wrong?” [You're trying to parse HTML using regular expressions.](http://stackoverflow.com/a/1732454/41071) – svick Sep 11 '13 at 10:55
  • I know you shouldn't have HTML in a regular expression but why did it work with and not with

    ? How do I format it so I leave out the HTML? What is the correct way to write this?

    – LTech Sep 11 '13 at 11:32

1 Answers1

0
    '%<div class="list-block"[^>]*>\n?<h2>(.+)</h2>\n?(<div id="list">)?(.*)(</div>)?\n?</div>\n</div>%sU'`

Is working now, I'm not sure what the issue was, it could have been a mediawiki formatting issue.

LTech
  • 1,677
  • 5
  • 29
  • 48