Regular express question

E

elca

Hello,
i have some text document to parse.
sample text is such like follow
in this document, i would like to extract such like
SUBJECT = 'NETHERLANDS MUSIC EPA'
CONTENT = 'Michael Buble performs in Amsterdam Canadian singer Michael Buble
performs during a concert in Amsterdam, The Netherlands, 30 October 2009.
Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK '

if anyone help me,much appreciate

"
NETHERLANDS MUSIC EPA | 36 before
Michael Buble performs in Amsterdam Canadian singer Michael Buble performs
during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble
released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK
"
 
A

alex23

Hello,
i have some text document to parse.
sample text is such like follow
in this document, i would like to extract such like
SUBJECT = 'NETHERLANDS MUSIC EPA'
CONTENT = 'Michael Buble performs in Amsterdam Canadian singer Michael Buble
performs during a concert in Amsterdam, The Netherlands, 30 October 2009.
Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK '

if anyone help me,much appreciate

"
NETHERLANDS MUSIC EPA | 36 before
Michael Buble performs in Amsterdam Canadian singer Michael Buble performs
during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble
released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK
"

You really don't need regular expressions for this:
.... NETHERLANDS MUSIC EPA | 36 before
.... Michael Buble performs in Amsterdam Canadian singer Michael Buble
performs
.... during a concert in Amsterdam, The Netherlands, 30 October 2009.
Buble
.... released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK
.... '''
text = text.strip() # remove eol markers
subject = text.split(' | ')[0]
content = ' '.join(text.split(eol)[1:])
subject 'NETHERLANDS MUSIC EPA'
content
"Michael Buble performs in Amsterdam Canadian singer Michael Buble
performs during a concert in Amsterdam, The Netherlands, 30 October
2009. Buble released his new album entitled 'Crazy Love'. EPA/OLAF
KRAAK"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top