开发者

Remove all text between 2 sentences in regex

开发者 https://www.devze.com 2023-01-14 01:51 出处:网络
I going crazry with regex. I need to extract a words between FROM and WHERE in this syntax: SELECT IDClient, Cli开发者_StackOverflow中文版ent FROM Client WHERE IDClient = 1 GROUP BY IDClient, Client

I going crazry with regex.

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

SELECT IDClient, Cli开发者_StackOverflow中文版ent FROM Client WHERE IDClient = 1 GROUP BY IDClient, Client ORDER BY IDClient

result = Client

How can I resolve this using regular expressions?


/FROM (.*) WHERE/i


(?<=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.


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


You can use this online regular expression builder:

  • http://gskinner.com/RegExr/

Or try the tutorials at:

  • regular-expressions dot info
0

精彩评论

暂无评论...
验证码 换一张
取 消