In [4]:
import re

In [8]:
s ='\n#here's a title\n\nhello world!!!\n\nPosted on 11-09-2014 02:32:30'


  File "<ipython-input-8-53c97802230d>", line 1
    s ='\n#here's a title\n\nhello world!!!\n\nPosted on 11-09-2014 02:32:30'
                ^
SyntaxError: invalid syntax

In [5]:
s ='\n#heres a title\n\nhello world!!!\n\nPosted on 11-09-2014 02:32:30\n'

In [6]:
# this grabs the title
re.findall(r'#.+\n',s)[0][1:-1]


Out[6]:
'heres a title'

In [9]:
#this grabs the date
re.findall(r'Posted on .+\n',s)[0][10:-1]


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-9-3630455036d1> in <module>()
      1 #this grabs the date
----> 2 re.findall(r'Posted on .+\n',s)[0][10:-1]

IndexError: list index out of range

In [14]:
#this grabs the date
re.findall(r'Posted on [\d\-\s:]+',s)


Out[14]:
['Posted on 11-09-2014 02:32:30']

In [15]:
re.findall(r'^[#\W+]',s)


Out[15]:
['\n']

In [17]:
re.findall(r'^[\W+]',s)


Out[17]:
['\n']

In [45]:
# result = re.findall(r'#.+\n(.*?)\n+Posted on .*?\n', s, re.MULTILINE | re.DOTALL)
result = re.search(r'#([^\n]+)\n+(.*)\n+(Posted on [^\n]*)', s, re.MULTILINE | re.DOTALL)
result


Out[45]:
<_sre.SRE_Match at 0x7f0eea6eb588>

In [47]:
regex = re.compile(r'#([^\n]+)\n+(.*)\n+(Posted on [^\n]*)', re.MULTILINE | re.DOTALL)
result = regex.search(s)
result


Out[47]:
'heres a title'

In [ ]: