My users want to be able to cut and paste a plain text email message into Application Express, and have the content of the email parsed and populate records in a table. The email messages are typically 10,000 – 20,000 characters, so I can put the email into a VARCHAR2 or a CLOB.
What I’m asking is for guidiance / pseudocode / hints for a way to parse these emails once I’ve populated the VARCHAR2 or the CLOB.
The messages have the following format:
Item One: content for item one
Item Two:
multiline content for item two
more multiline content for item two
********************************* <- these asterisks are in the text
Section Header I don't care about
*********************************
Item Three: content for item three
and so on.
The item headers are known in advance, and are in a constant and defined order.
I’d prefer to do this via PL/SQL as this will be implemented in the Oracle hosted Apex instance, but I believe Java can be used there as well (PL/SQL is much preferred).
The following code gives you an example of how to use instr and substr. All you need further is a way to put this code in a loop and populate l_header_first and l_header_next so you can get all the values you want.