Regular expression for detecting round brackets

前端 未结 3 1790
夕颜
夕颜 2021-01-24 18:23

I have a large array with string. Now, I need to use the string in the array to form patterns. However for the string with round brackets, the constructed patterns don\'t work.

3条回答
  •  攒了一身酷
    2021-01-24 18:55

    Because in line String text = "Student (male): John"; does not match with regex student \(male\)\:\s\w+

    Replace input text with text = "student (male): John"; or first phrase strings to phrases[0] = "Student (male)";

    Example on Ideone

提交回复
热议问题