小编cho*_*pss的帖子

删除句子和段落之间的各种额外空格

我想删除句子之间的各种额外空格,并将其作为一个字符串进行处理

例如:

The meaning of the phrase "ice cream" varies from one country to another. Phrases 
such as "frozen custard", "frozen yogurt", "sorbet", "gelato" and others are used 
to distinguish different varieties and styles.

In some countries, such as the United States, the phrase "ice cream" applies only
to a    specific variety, and most governments regulate the commercial use of
the   various terms according to the relative quantities of the main ingredients. 

Products that do not meet the criteria to …
Run Code Online (Sandbox Code Playgroud)

java regex string

1
推荐指数
1
解决办法
1482
查看次数

提取时间的正则表达式

我想从文本中提取时间,无论它是什么格式.例如:这个

1)06/02/2009:周二早上大约上午8:30,在俄罗斯印古什的纳兹兰,一个简易爆炸装置(简易爆炸装置)被放置在属于Isa Tochiyev上校的车辆下面.共和国禁毒部门的人身安全因警察与他的家人在莫斯科夫斯卡娅街上开车,杀害警察,伤害两名儿童并损坏车辆而爆炸.简易爆炸装置装满了100至200克炸药.

产量

上午8:30

 Pattern p = Pattern.compile("(\\d{1,2}[.:]\\d{2}\\s?[AaPp]\\.?[Mm])");
Matcher m = p.matcher(str);
if(m.find())
 {
 System.out.println("The time is " + m.group(0));
 }
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助我,而不是给予序列化的投票.....

java regex

-1
推荐指数
1
解决办法
136
查看次数

标签 统计

java ×2

regex ×2

string ×1