Solved

returning text

Posted on 2013-01-31
2
193 Views
Last Modified: 2013-02-05
Hi
Have a large text file and I want to capture all text with the following conditions
i.e.any text that has "from" and "on" (all text between these words) - example ..

"select * from table1
inner join table 2 on t1.id = t2.id
blah blah
blah blah
blah blah
when the test data is from wherever and
my data is on alert then
etc"

so, I want the following returned ... a single row for each capture
from table1 inner join table 2 on
from wherever and my data is on

my attempt so far ..
File.open("c:/regex.txt").each  do |f|
      if f =~/(?<=from[\s\w\d\r\n])+(?=on)+/i then
            puts f
      end
end

Regards
0
Comment
Question by:PHIL Sawyer
2 Comments
 
LVL 10

Accepted Solution

by:
Andrew Doades earned 500 total points
ID: 38847219
0
 

Author Closing Comment

by:PHIL Sawyer
ID: 38854879
Thanks
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
a way to send emails from Ruby programming 2 315
Ruby on Rails/Postgres --- Looks to be a query issue? 7 714
How do you upgrade Ruby? (Windows) 2 211
is this a cms? 8 60
I recently rediscovered rails when I needed a holiday project and decided to build a management dashboard for the company where I work.  With it being a project done in my free time, I could focus my time on learning the basics rather than trying to…
In Ruby, Call or invoke a API DLL library is easily via Win32API class, win32-api gem or other gems. For general DLL API call, there are quite a few references, some good tips list below: http://www.rubytips.org/2008/05/13/accessing-windows-api-fro…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question