Home java How to make friends Split with Cyrillic? Java

How to make friends Split with Cyrillic? Java

Author

Date

Category

You need to split the string into separate words. Made so. It works well with the text written by the Latin. But the words written by Cyrillic does not recognize. Tell me what can be done?

Public Class TextSplitter {

public arraylist & lt; string & gt; SplittextTowOWords (String String) {
  ArrayList & LT; String & GT; List = New ArrayList & LT; & GT; ();
  String [] strings = string.split ("\\ w");
  For (int i = 0; i & lt; strings.length; I ++) {
    if (Strings [i] .length () & gt; 0) {
      List.add (strings [i] .TolowerCase ());
    }
  }
  RETURN LIST;
}

Answer 1, Authority 100%

You can try this to add Cyrillic

string [] strings = string.split ("[^ a-za-za-ya-ya0-9_] ");

or divide on spaces

string [] strings = string.split ("\\ s");

But the first is better for me. Because the second divides on spaces.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions