[ create a new paste ] login | about

Link: http://codepad.org/TAXfTRFr    [ raw code | output | fork ]

Python, pasted on Oct 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import re

wikiText = """==Mainsection1==
Some text here
===Subsection1.1===
Other text here

==Mainsection2==
Text goes here
===Subsecttion2.1===
Other text goes here. """

outputArray = re.findall('(?<!=)==([^=]+)==(?!=)([\s\S]*?(?=$|(?<!=)==[^=]+==(?!=)))', wikiText)
print outputArray

outputArray = re.findall('(?<!=)==([^=]*)==(?!=)([^=]*)', wikiText, re.MULTILINE)
print outputArray


Output:
1
2
[('Mainsection1', '\nSome text here\n===Subsection1.1===\nOther text here\n\n'), ('Mainsection2', '\nText goes here\n===Subsecttion2.1===\nOther text goes here. ')]
[('Mainsection1', '\nSome text here\n'), ('Mainsection2', '\nText goes here\n')]


Create a new paste based on this one


Comments: