using lookahead and lookbehind

Hi
In my regular expression I use a lookahead and lookbehind to match anything between the words "join" and "on".
This I have done using ..
....
file_out1 = File.open('regex1_output1b.txt','w')
File.foreach("SCHEMA.txt"){ |line|
            line = line.scan(/(?<=\sjoin\s).*(?=on)/i)
            puts line
            file_out1.puts( line)
            }      
file_out1.close      
However - I also want to include any lines from my "SCHEMA.txt" file where the line starts with "create".
How can I do this?

Regards
PHIL SawyerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
/(?!^create).*(?<=\sjoin\s).*(?=on)/
0
PHIL SawyerAuthor Commented:
Hi
If I use /(?!^create).*(?<=\sjoin\s).*(?=on)/ then I get the whole line with "join" in it up to anything before the word "on". Plus, no lines with "create"!
Some example returns using the above logic
INNER JOIN Schema_A.V_PRODUCT T2
INNER JOIN Schema_A.V_FLAT_CLASS T3
--LEFT JOIN Schema_A.PRODUCT_COMMENTARY PC
LEFT JOINSchema_A.PRODUCT_COMMENTARY PC
LEFT JOINSchema_A.PRODUCT PR
from v_terms_all lta inner join Schema_A.PRODUCT p

Regards
0
ozoCommented:
What would you prefer to get?
how about
line = line.scan(/^(?!create)(?:.*?)(?<=\sjoin\s)(.*)(?=on)/i)
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

PHIL SawyerAuthor Commented:
Hi ozo
This is better but I still do not get any lines returned where the line starts with "create"
Regards
0
ozoCommented:
Sorry, I thought you said you wanted to not get any lines returned where the line starts with "create"
If you want lines returned where the line starts with "create"
   line = line.scan(/(^create.*|(?<=\sjoin\s).*(?=on))/i)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PHIL SawyerAuthor Commented:
That did it - many thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Regular Expressions

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.