Bug 563121 - Fix p2 PatternFilter.

Change-Id: I61fec3df35df1774bc5586bc6354942f09482068
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
index 7724931..eb29940 100644
--- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
+++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
+ * Copyright (c) 2004, 2020 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -14,8 +14,9 @@
  *******************************************************************************/
 package org.eclipse.equinox.internal.p2.ui.discovery.util;
 
-import java.text.BreakIterator;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
 import org.eclipse.jface.viewers.*;
 import org.eclipse.ui.internal.misc.StringMatcher;
 
@@ -58,6 +59,8 @@
 
 	private static Object[] EMPTY = new Object[0];
 
+	private static final Pattern NON_WORD = Pattern.compile("\\W+", Pattern.UNICODE_CHARACTER_CLASS); //$NON-NLS-1$
+
 	@Override
 	public final Object[] filter(Viewer viewer, Object parent, Object[] elements) {
 		// we don't want to optimize if we've extended the filter ... this
@@ -270,31 +273,7 @@
 	 * @return an array of words
 	 */
 	private String[] getWords(String text) {
-		List<String> words = new ArrayList<>();
-		// Break the text up into words, separating based on whitespace and
-		// common punctuation.
-		// Previously used String.split(..., "\\W"), where "\W" is a regular
-		// expression (see the Javadoc for class Pattern).
-		// Need to avoid both String.split and regular expressions, in order to
-		// compile against JCL Foundation (bug 80053).
-		// Also need to do this in an NL-sensitive way. The use of BreakIterator
-		// was suggested in bug 90579.
-		BreakIterator iter = BreakIterator.getWordInstance();
-		iter.setText(text);
-		int i = iter.first();
-		while (i != java.text.BreakIterator.DONE && i < text.length()) {
-			int j = iter.following(i);
-			if (j == java.text.BreakIterator.DONE) {
-				j = text.length();
-			}
-			// match the word
-			if (Character.isLetterOrDigit(text.charAt(i))) {
-				String word = text.substring(i, j);
-				words.add(word);
-			}
-			i = j;
-		}
-		return words.toArray(new String[words.size()]);
+		return NON_WORD.split(text, 0);
 	}
 
 	/**