0

I've try to replace this <?= T_('XXX'); ?> for this {{ T_('XXX') }}, I've try this

<\\?= \\([^\\?]+\\) *\\?> -> {{ $1 }}

and can't make it work. What regex and replacement should I use.

PS: is there online Regex tool for Emacs, there is lot of tools out there but I can't find one for emacs (maybe there is tool in emacs itself).

3
  • M-x isearch-forward-regexp Commented Mar 11, 2014 at 14:41
  • quick help: wikemacs.org/index.php/Regexp Commented Mar 11, 2014 at 14:46
  • @abo-abo it's great, excactly what I was looking for to test and learn Regex in Emacs. Commented Mar 11, 2014 at 22:03

2 Answers 2

1

This code will do the replacement, point has to be at buffer start:

(replace-regexp "<\\?=\\([^;]+\\); \\?>"
                "{{\\1 }}")

Interactively it's M-x replace-regexp, but each two backslashes from above you have to replace with just one.

Sign up to request clarification or add additional context in comments.

1 Comment

That was my bad, I've used double backslashes while using M-x.
0

IIUC you don't need a regexp, a simple string replace will do it:

M-x query-replace RET
<?=
RET
{{

and then

M-x query-replace RET
; ?>
RET
 }}

1 Comment

It's not good because ?> can start with <? if and <? if should have {% so it need %} (It's twig, same as django I think)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.