Regex to add a character at nth position?

2019-09-12 13:34发布

I have this text:

1111111111111111111111111111111111111111111111111

where I need to add character at fifth position to have this result

11111A11111111111111111111111111111111111111111111

I tried with

(?<=.{5})

Replace with

A

it puts A after fifth character but continue to ad to every next five characters.

I am using Powergrep. How to make it to stop after first occurence?

标签: regex replace
1条回答
我想做一个坏孩纸
2楼-- · 2019-09-12 14:21

You could use the ^ character to anchor the regular expression to the start of the string:

(?<=^.{5})

See regex tester

查看更多
登录 后发表回答