How to match everything up to the second occurrence of a character?

前端 未结 2 598
深忆病人
深忆病人 2020-12-15 17:49

So my string looks like this:

Basic information, advanced information, super information, no information

I would like to capture everything

2条回答
  •  生来不讨喜
    2020-12-15 18:17

    You could try ^(.*?,.*?), The problem is that .* is greedy and matches maximum amount of characters. The ? behind * changes the behaviour to non-greedy.

    You could also put the parenthesis around each .*? segment to capture the strings separately if you want.

提交回复
热议问题