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

  • Home
  • SEARCH
  • 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 8684765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:23:22+00:00 2026-06-12T22:23:22+00:00

Possible Duplicate: Replace while keeping certain words in vi/vim Let’s say I have several

  • 0

Possible Duplicate:
Replace while keeping certain “words” in vi/vim

Let’s say I have several lines like

            $adv_id;
            $am_name; 
            $campaign_ids;
            $repeat_on;
            $opt_days;
            $opt_time;
            $am_or_pm;

Let’s say I use visual mode to select all the lines.. how can I add characters at the start and the end of each line so it looks something like

        $_REQUEST($adv_id);
        $_REQUEST($am_name; 
        $_REQUEST($campaign_ids);
        $_REQUEST($repeat_on;
        $_REQUEST($opt_days);
        $_REQUEST($opt_time);
        $_REQUEST($am_or_pm);
  • 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-06-12T22:23:23+00:00Added an answer on June 12, 2026 at 10:23 pm

    Pretty similar to your other question, so the explanation there should help you to understand this substitute. With the lines selected as a visual block, use this substitute command:

    :'<,'>s/\$\(.*\);/$_REQUEST(\1);
    

    As before, the '<,'> will be auto-filled for you in the command-line if you have a visual selection.

    The difference here is that we’re using \(\) to make a capturing group, which will capture part of the regex, and use it again in the replacement, using \1, which refers to the first capturing group.

    Also, since this regex uses $ literally to position the replacement, it needs to be escaped: \$, since it has a special meaning in the regex: end of line.

    If you’ll need to have multiple replacements on a single line, you’ll need to add the g flag, and you may want to remove the semicolon:

    :'<,'>s/\$\(.*\);/$_REQUEST(\1)/g
    

    The reverse regex, e.g. replacing $_REQUEST($adv_id); with $adv_id;, is pretty similar:

    :'<,'>s/\$_REQUEST(\(.*\))/\1
    

    Here we capture everything between the parens in a $_REQUEST(...); in a capturing group, and that capturing group is the entire replacement.

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

Sidebar

Related Questions

Possible Duplicate: How to replace several words in javascript I have a string: var
Possible Duplicate: Replace words in a string, but ignore HTML Is it possible to
Possible Duplicate: Replace individual list elements in Haskell? I have managed to make some
Possible Duplicate: Preg Replace - replace second occurance of a match I have a
Possible Duplicate: Why does javascript replace only first instance when using replace? I have
Possible Duplicate: php regular expression help? hi, i want to replace i like apple
Possible Duplicate: Replace only first match using preg_replace I have a string as follows:
Possible Duplicate: replace all occurrences in a string I have this string: 12-3-02 And
Possible Duplicate: JavaScript replace all / with \ in a string? I have a
Possible Duplicate: How to replace string in SQLite? I have a table column data

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.