Solved

returning text

Posted on 2013-01-31
2
183 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Ruby on Rails 4 453
Routing in Rails 3 3 681
Find instance method "where" in Rails Docs 5 460
Rails URL Rewrite 1 413
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now