I'm currently working on a project in Ruby on Rails (in Eclipse) and my task is to split up a block of data into relevant parts using Regular Expressions.
I've decided to break up the data based on 3 parameters:
- The line must start with a capital letter (RegEx equivalent -
/^[A-Z]/
) - It must end with a : (RegEx equivalent -
/$":"/
)
I would appreciate any help....The code I'm using in my controller is:
@f = File.open("report.rtf")
@fread = @f.read
@chunk = @fread.split(/\n/)
where @chunk
is the array that will be created by the split and @fread
is the data that is being split up (by new lines).
Any help will be appreciated, thanks a lot!
I cannot release the exact data but it goes basically by this (this is medically related)
Exam 1: CBW 8080
RESULT:
This report is dictated with specific measurement. Please see the original report.
COMPARISON: 1/30/2012, 3/8/12, 4/9/12
RECIST 1.1: BLAH BLAH BLAH
The ideal output would be an array that says:
["Exam 1:", "CBW 8080", "RESULT", "This report is dictated with specific measurement. Please see the original report.", "COMPARISON:", "1/30/2012, 3/8/12, 4/9/12", "RECIST 1.1:", "BLAH BLAH BLAH"]
PS I'm just using \n as a placeholder until I get it working