Forum Academy Marketplace Showcase Pricing Features

Parsing a string of text and extracting bits of it out based on a matching piece of text

Hi all,

So I have a block of text in a field like this (data is extracted from a web scraper):

Title blah blah blah Description blah blah blah Opportunity blah blah blah Contact Details blah blah blah

Basically I would like to know how I could pull out and parse/assign the following into separate data fields:

  • Title and then all the text “blah blah blah” contained before “Description”
  • Description and then all the text “blah blah blah” contained before “Opportunity”
  • Contact Details and then all the text “blah blah blah” contained before “Contact Details”

I would rather avoid having to do this within the web scraper as it is really quite complex to do it that way.

Cheers,
Dav

:find & replace with a regular expression should help …

Pattern: Title(.+?)Description.+
Replace with: $1

Experiment here:

1 Like

aweosme thanks! this solved it (propmted by your idea) http://stackoverflow.com/questions/3855654/regular-expressions-how-do-i-grab-a-block-of-text-using-regex-in-ruby

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.