java regex将字符作为特定索引位置插入 [英] java regex insert character as specific index position

查看:77
本文介绍了java regex将字符作为特定索引位置插入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在字符串的第3个位置插入字符/。

I need to simply insert character "/" in the 3rd position of string.

EURUSD变成EUR / USD

我正在使用一些程序GUI来执行此操作,它接受一个正则表达式模式和替换。

I'm using some program GUI to do this, it accepts a Regex Pattern and a Replacement.

我知道这一定非常简单,但我似乎找不到简单的答案。

I know this must be super simple but I can't seem to find a simple answer.

推荐答案

替换 ^。{3} (3 [ {3} ]字符[ ]在字符串[ ^ ]的开头, $& / (匹配 $& ,后跟 / )。

Replace ^.{3} (3 [{3}] characters [.] at the start of the string [^]) with $&/ (the match $&, followed by a /).

这篇关于java regex将字符作为特定索引位置插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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