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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:54:57+00:00 2026-05-24T18:54:57+00:00

In vimscript I can regexp-match stuff with matchstr() and matchlist() But what if I

  • 0

In vimscript I can regexp-match stuff with matchstr() and matchlist()

But what if I have to append to the pattern a user-provided string?
How can I quote meta characters in that?

  • 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-24T18:54:58+00:00Added an answer on May 24, 2026 at 6:54 pm

    I don’t think there’s anything that does that, but you could use a magicness modifier which might be good enough. Let’s say you have the following expression:

    let pattern = '\<'.word.'\>'
    

    if word is a user-supplied string, then (if I understand correctly) you’d like to ignore all special modifiers in it. To do that, use “very nomagic mode”. By putting a “\V” in front of the pattern, you make the pattern behave almost like a literal string. Afterwards, put “\m” to restore normal behaviour. In this case:

    let pattern = '\<\V'.word.'\m\>'
    

    Note, however, that this is not exactly what you’re asking for. If the user enters foo(*bar), it will work just fine, but if it’s foo(\*bar), it won’t, because the \* pair is being interpreted as a star modifier. If you don’t know about these modes, try :help /\V to get a better idea of how magicness works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way I can query from within Vim information about user-defined vimscript
How can you check if a string is a valid GUID in vbscript? Has
let test = 'a href=http://www.google.com>www.google.com</a;' In vimscript, how can I get http://www.google.com out of
I have a function in VBScript, what is it doing? how can I simplify
I have just tried enabling php_browscap.ini so that I can use the get_browser function.
I have vim 7.2 (-clipboard -xterm_clipboard ...) in Ubuntu. You can see that it's
Let's say I have a bunch of text like this (simplified example, but you
I can not create a directory in russian (UTF-8) using vimscript in WinXP. For
Is there something like a close-window-hook in vim/vimscript, so that I can call a
I have got below function in VBSCript. How can this be writtern in C#.

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.