pedrofernandes
pedrofernandes

Reputation: 16854

Remove all text between 2 sentences in regex

I going crazry with regex.

I need to extract a words between FROM and WHERE in this syntax:

SELECT IDClient, Client FROM Client WHERE IDClient = 1 GROUP BY IDClient, Client ORDER BY IDClient

result = Client

How can I resolve this using regular expressions?

Upvotes: 0

Views: 450

Answers (4)

Rami C
Rami C

Reputation: 1933

You can use this online regular expression builder:

Or try the tutorials at:

  • regular-expressions dot info

Upvotes: 0

rrrr-o
rrrr-o

Reputation: 2516

(?<=FROM\s+).*(?=\s+WHERE)

That uses a look behind and a lookahead to get what is between FROM and WHERE, and can be modified depending on whether you want the whitespace or not.

Upvotes: 1

Jan.
Jan.

Reputation: 1995

/FROM (.*) WHERE/i

Upvotes: 2

fredley
fredley

Reputation: 33901

Use a regex cheat sheet, it's not too hard to work out.

Upvotes: 0

Related Questions