开发者

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, 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜