Remove all non alphabetic characters from a String array in java

后端 未结 8 952
难免孤独
难免孤独 2020-12-14 08:11

I\'m trying to write a method that removes all non alphabetic characters from a Java String[] and then convert the String to an lower case string. I\'ve tried u

8条回答
  •  遥遥无期
    2020-12-14 08:41

    You need to assign the result of your regex back to lines[i].

    for ( int i = 0; i < line.length; i++) {
      line[i] = line[i].replaceAll("[^a-zA-Z]", "").toLowerCase();
    }
    

提交回复
热议问题