Saturday, March 25, 2017

Re: Translate \u0041 to A

On Sa, 25 Mär 2017, JohnBeckett wrote:

> Given this text:
>
> A\u0042C\u0044E
>
> What substitute changes it to:
>
> ABCDE

Something like this:
:%s/\\u\(\x\{4\}\)/\=nr2char('0x'.submatch(1),1)/g

or with a function like this:

func! String(match)
exe 'return "'.a:match.'"'
endfunc

And then:
:%s/\\u\x\{4\}/\=String(submatch(0))/g

Best,
Christian
--
Abschied nehmen ist immer schmerzlich, selbst wenn es nur für kurze
Zeit ist.
-- Anne Morrow Lindbergh (Muscheln in meiner Hand)

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: