split not working correctly

前端 未结 4 851
误落风尘
误落风尘 2021-01-18 16:21

I am trying to save the groups in a string to an array so that I can use them in individual variables if I need to. For this I use split but for some reason I only

4条回答
  •  盖世英雄少女心
    2021-01-18 17:10

    The split takes an regular expression and $ is a special character (end of string) so you have to escape it with backslash \. Anyway it is also special character, this time in Java, so you have to escape it also. The final code is:

    ultimate_array = string_final.split("#\\$");
    

提交回复
热议问题