Solved

returning text

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Free Ruby on Rails hosting 4 524
require 'icalendar' causes error 1 467
trying to get text between certain words 6 215
return files 6 102
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…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

22 Experts available now in Live!

Get 1:1 Help Now