Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 204827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:30:08+00:00 2026-05-11T17:30:08+00:00

I love emacs. I love regexs. I hate emacs’ regex syntax – the need

  • 0

I love emacs. I love regexs. I hate emacs’ regex syntax – the need to escape grouping parens and braces, that you dont escape literal parens, the lack of predefined character classes, etc.

Can I replace emacs’ regex engine, or tweak some setting, so that when I use the Query-replace-regexp (or one of many other) feature I can use the syntax I program with in java/js/perl/ruby/etc…?

Edit:
The subject was originally “how to change emacs’ regex engine” which would not only change escaping rules and add character classes, but also (not mentioned in the post) add support for various common extensions (?…). Features like non-capturing parens: (?:…), match only if/if-not followed by: (?=…)/(?!…), and others. I don’t believe (though happy to be corrected) these are possible with emacs’ current regex engine, and no amount of syntax replacements will fix that.

The solution below addresses the original issues of escaping and additional char classes by replacing with syntax emacs understands. A second answer (now deleted) suggested advising (add a function to run at the start of another) emacs’ regex function to do the replacement for all regex processing. The author quickly censored him/herself realizing that it would likely break much existing emacs code, and eventually the post was removed.

I would still like to change the regex-engine to one which supports extensions, but I agree that changing the escaping behavior universally would cause havoc I’m not willing to chase. Thus, I’m changing the subject to match the question and accepting the response.

It crossed my mind to change the engine to support common-syntax and extensions, advise the regex function to convert emacs-internal code to common-syntax, advise the interactive functions to convert my common-syntax to emacs-syntax (so it can be converted back to common)… but I think even RMS would recommend a fork before that.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T17:30:08+00:00Added an answer on May 11, 2026 at 5:30 pm

    You could define your own elisp function which modified the regexp and then passed it back to emacs. In pseudo-elisp:

    (defun my-query-replace-regexp (regexp)
        ; modify regexp to replace ( with \(, { with \{, etc.
        (query-replace-regexp modified-regexp)
    )
    
    ; rebind C-% to use new regexp function
    (global-set-key "\C-%" 'my-query-replace-regexp)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running Emacs, editing files in C++ mode and PHP mode. I love syntax
I love using GDB withing emacs. And I most like the configuration that I
Love TextMate, love Python, blah, blah, blah .. But.. i hate that Docstrings, aka
I'm an avid Emacs user and love shell-mode that in my opinion brings the
I really love org-mode in emacs and want to customize a few things. While
I love paredit. But there are a couple of things I hate, and have
I love Jenkins and appreciate that it is an active project. Still, I don't
I love LINQ to SQL but it has been bugging me that in using
I love Ruby and its framework, but I don't think that Ruby On Rails
I love triggers for one reason - they just work. I hate triggers for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.