当的空间,随后通过四个数字添加标识符 [英] Add an identifier when a space is followed by four digits

查看:131
本文介绍了当的空间,随后通过四个数字添加标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处理的字符串,

30-Nov-2012 30-Nov-2012 United Kingdom, 31-Oct-2012 31-Oct-2012 United Arab Emirates, 29-Oct-2012 31-Oct-2012 India 

我需要每一个四位数字后,空间显得时间,即添加空格:

I need to add spaces every time a space appears after a four digit numbers, i.e.:

30-Nov-2012@30-Nov-2012@United Kingdom, 31-Oct-2012@31-Oct-2012@United Arab Emirates, 29-Oct-2012@31-Oct-2012@India 

我不知道该怎么写普通防爆pressions,任何帮助吗?

I don't know how to write Regular Expressions, any help please?

推荐答案

既然你不知道怎么写普通防爆pressions,最好的办法是学习如何使用正防爆pressions。

Since you don't know how to write Regular Expressions, your best bet is learning how to use Regular Expressions.

下面是一个pretty很好的教程。

Here's a pretty good tutorial.

http://www.vogella.com/articles/JavaRegularExpressions / article.html

你想写的前pression似乎并不十分复杂。您应该能够通过本教程会后做了。

The expression you want to write doesn't seem very complicated. You should be able to do it after going through this tutorial.

编辑:这是另一条线索。看看的replaceAll

Here's another hint. Take a look at replaceAll

和也看看积极lookbehinds

EDIT2:我很无聊,所以这里的答案。

I'm bored, so here's the answer.

string.replaceAll("(?<=\\d{4})\\s", "@");

这篇关于当的空间,随后通过四个数字添加标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆