Priority in regex manipulating

后端 未结 4 772
[愿得一人]
[愿得一人] 2021-01-26 15:28

I write some java code to split string into array of string. First, I split that string using regex pattern \"\\\\,\\\\,|\\\\,\" and then I split using pattern

4条回答
  •  一生所求
    2021-01-26 16:22

    It will be evaluated from left to right. In regex1, \\,\\, is tried first, otherwise \\, is tried. That's why 12th String is not empty, because \\,\\, is matched in that case. For regex2, everything is matched using \\,, hence the empty String.

提交回复
热议问题