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 3215610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:11:52+00:00 2026-05-17T15:11:52+00:00

I noticed that vim’s substitute regex is a bit different from other regexp. What’s

  • 0

I noticed that vim’s substitute regex is a bit different from other regexp. What’s the difference between them?

  • 1 1 Answer
  • 0 Views
  • 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-17T15:11:52+00:00Added an answer on May 17, 2026 at 3:11 pm

    If by “normal regex” you mean Perl-Compatible Regular Expressions (PCRE), then the Vim help provides a good summary of the differences between Vim’s regexes and Perl’s:

    :help perl-patterns
    

    Here’s what it says as of Vim 7.2:

    9. Compare with Perl patterns                           *perl-patterns*
    
    Vim's regexes are most similar to Perl's, in terms of what you can do.  The
    difference between them is mostly just notation;  here's a summary of where
    they differ:
    
    Capability                      in Vimspeak     in Perlspeak ~
    ----------------------------------------------------------------
    force case insensitivity        \c              (?i)
    force case sensitivity          \C              (?-i)
    backref-less grouping           \%(atom\)       (?:atom)
    conservative quantifiers        \{-n,m}         *?, +?, ??, {}?
    0-width match                   atom\@=         (?=atom)
    0-width non-match               atom\@!         (?!atom)
    0-width preceding match         atom\@<=        (?<=atom)
    0-width preceding non-match     atom\@<!        (?!atom)
    match without retry             atom\@>         (?>atom)
    
    Vim and Perl handle newline characters inside a string a bit differently:
    
    In Perl, ^ and $ only match at the very beginning and end of the text,
    by default, but you can set the 'm' flag, which lets them match at
    embedded newlines as well.  You can also set the 's' flag, which causes
    a . to match newlines as well.  (Both these flags can be changed inside
    a pattern using the same syntax used for the i flag above, BTW.)
    
    On the other hand, Vim's ^ and $ always match at embedded newlines, and
    you get two separate atoms, \%^ and \%$, which only match at the very
    start and end of the text, respectively.  Vim solves the second problem
    by giving you the \_ "modifier":  put it in front of a . or a character
    class, and they will match newlines as well.
    
    Finally, these constructs are unique to Perl:
    - execution of arbitrary code in the regex:  (?{perl code})
    - conditional expressions:  (?(condition)true-expr|false-expr)
    
    ...and these are unique to Vim:
    - changing the magic-ness of a pattern:  \v \V \m \M
       (very useful for avoiding backslashitis)
    - sequence of optionally matching atoms:  \%[atoms]
    - \& (which is to \| what "and" is to "or";  it forces several branches
       to match at one spot)
    - matching lines/columns by number:  \%5l \%5c \%5v
    - setting the start and end of the match:  \zs \ze
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I noticed that Feedzirra uses this regex to get the ETag from response header:
I've noticed that git seems to use different vim settings any time I'm writing
I noticed that most of the time, when using some encoding other than 'the
I just ran :help registers in Vim and noticed that # 'contains the name
I noticed that it is very slow for a Regex to finish a XML
Have you ever noticed (not only in Vim) that the cursor never change position
I'm looking to install vim-latex for mac, and in doing so, I've noticed that
How can I export vim folds from a file, so that I can transfer
I noticed that various systems use various characters as the replacent for illegal ones
I noticed that on my Vista and XP machines, the automatic update is asking

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.