What Regex would capture everything from ' mark to the end of a line?

前端 未结 7 1554
南方客
南方客 2020-12-12 16:32

I have a text file that denotes remarks with a single \'.

Some lines have two quotes but I need to get everything from the first instance of a \

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-12 17:27

    In your example I'd go for the following pattern:

    '([^\n]+)$
    

    use multiline and global options to match all occurences.

    To include the linefeed in the match you could use:

    '[^\n]+\n
    

    But this might miss the last line if it has no linefeed.

    For a single line, if you don't need to match the linefeed I'd prefer to use:

    '[^$]+$
    

提交回复
热议问题