String [] words = s.split(“[^ a-zA-Z] +”); [重复]

时间:2022-09-18 21:43:44

This question already has an answer here:

这个问题在这里已有答案:

What does it mean "[^a-zA-Z]+" ?

这是什么意思“[^ a-zA-Z] +”?

I am a beginner in JAVA and not getting what does it mean .

我是JAVA的初学者而没有得到它的意思。

3 个解决方案

#1


1  

It means split the string on sequences of one or more consecutive non-letters. Study https://en.wikipedia.org/wiki/Regular_expression

这意味着将字符串拆分为一个或多个连续非字母的序列。学习https://en.wikipedia.org/wiki/Regular_expression

Eg. if s="abc, zzz!,ccc=ddd0eee" then words = {"abc", "zzz", "ccc", "ddd", "eee"}

例如。如果s =“abc,zzz!,ccc = ddd0eee”则words = {“abc”,“zzz”,“ccc”,“ddd”,“eee”}

#2


0  

It's called RegEx , or Regular Expression , which defines a search pattern into a String.

它被称为RegEx或Regular Expression,它将搜索模式定义为String。

You can find a good tutorial with examples here

你可以在这里找到一个很好的教程

#3


0  

It's regular expression. This one mean "match all strings that contain a non-letter". Also you can learn regex https://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/

这是正则表达式。这意味着“匹配包含非字母的所有字符串”。你也可以学习正则表达式https://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/

#1


1  

It means split the string on sequences of one or more consecutive non-letters. Study https://en.wikipedia.org/wiki/Regular_expression

这意味着将字符串拆分为一个或多个连续非字母的序列。学习https://en.wikipedia.org/wiki/Regular_expression

Eg. if s="abc, zzz!,ccc=ddd0eee" then words = {"abc", "zzz", "ccc", "ddd", "eee"}

例如。如果s =“abc,zzz!,ccc = ddd0eee”则words = {“abc”,“zzz”,“ccc”,“ddd”,“eee”}

#2


0  

It's called RegEx , or Regular Expression , which defines a search pattern into a String.

它被称为RegEx或Regular Expression,它将搜索模式定义为String。

You can find a good tutorial with examples here

你可以在这里找到一个很好的教程

#3


0  

It's regular expression. This one mean "match all strings that contain a non-letter". Also you can learn regex https://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/

这是正则表达式。这意味着“匹配包含非字母的所有字符串”。你也可以学习正则表达式https://www.marksanborn.net/howto/learning-regular-expressions-for-beginners-the-basics/