Solved

returning text

Posted on 2013-01-31
2
209 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 500 total points
ID: 38847219
0
 

Author Closing Comment

by:PHIL Sawyer
ID: 38854879
Thanks
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…
Suggested Courses

732 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