?
Solved

returning text

Posted on 2013-01-31
2
Medium Priority
?
223 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

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

Author Closing Comment

by:PHIL Sawyer
ID: 38854879
Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: narshlob
If you've ever programmed in Ruby and have come across either a proc or a lambda, you might have been wondering what the difference is between the two and when you would use one over the other. This article will try to explain the difference between…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

764 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