D
D
Dmitry Kuzmin2014-06-20 13:52:23
Perl
Dmitry Kuzmin, 2014-06-20 13:52:23

How to add a character after every 4 characters via regex?

There is a line of the form: 1234567890ABCDEF
It is necessary to bring it to the form \u1234\u5678\u90AB\uCDEF through perl regexp. That is
, put \u before every four characters.
Can't make an expression that would be a template for this.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amidart, 2014-06-20
@Dimkaa

$ perl -le '$s="1234567890ABCDEF"; $s =~ s/(\w{4})/\\u$1/g; print $s'
\u1234\u5678\u90AB\uCDEF

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question