What is the shortest regular expression I can write to insert 3 characters into a string?

I am looking for the most efficient use of RegEx to insert 3 characters into a string, 3 characters from the beginning.

Match : ABC123

Paste : 000

Result : ABC000123

My main goal is the effectiveness of my RegEx. So far, my economic attempts have not produced this result.

0
source share
2 answers

I think you can do this regex:

^(.{3})

Replace it:

$1000

Do not confuse the above with 1000. This is Group1 ( $1), followed by what you want to insert. In this case ( 000)

, objective-c, .

+3

:

s/ABC123/ABC000123/

, , , .

, .

0

Source: https://habr.com/ru/post/1534879/


All Articles