Regular Expression to end of line

时间:2017-12-18 08:03:42

标签: regex delphi

I'd like to find commented lines within a string using regular expressions. I tried the following but it gives me everything after the first line.split().

Why?

//

2 个答案:

答案 0 :(得分:1)

You should not use the following syntax in your regex: ORDER BY

This means taking all characters that are not dollar [^$]* 0 to N times (including $ character) what causes your regex to take the whole string.

Use that regex instead:

EOL

Good luck!

答案 1 :(得分:1)

You need to use

 Pattern := '//[^\r\n]*'

You may even remove the Pattern := '//.*'; option as you do not need to specify the end of line, roMultiLine will match 0+ chars other than line breaks, practically matcing any line to its end from the current position (here, after .*).