简体   繁体   English

Java正则表达式获取短语

[英]Java Regex to get phrases

I have a String list but with a lot of informations in it like dates, prices, numbers and phrases like this: 我有一个字符串列表,但其中包含很多信息,例如日期,价格,数字和短语,例如:

01/01/2018
123 -TESTING. PHRASE (I want to get this phrase)
98765
1.274.89

I can get the other information with a for loop and Regex, but I cannot make a Regex to match the phrases inside the list, only the dates the other numbers and prices, I tried somethings like this to match the phrases: 我可以使用for循环和Regex来获取其他信息,但是我无法使Regex匹配列表中的短语,仅匹配其他数字和价格的日期,我尝试了类似的方法来匹配短语:

^[a-zA-Z]\D+$
[\w[.*]]+

I'm starting to learn about Regex, and I'm having a lot of difficulties... 我开始学习正则表达式,并且遇到很多困难...

If a phrase is defined as a line containing text (as opposition to dates, prices and numbers), the following should be good 如果将短语定义为包含文本的行(与日期,价格和数字相反),则以下内容应为好

^.*\\[A-Za-z\\].*$

It just takes anything with a letter in it, may it be lower or uppercase. 它只需要包含字母的任何内容,可以是小写或大写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM