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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:57:45+00:00 2026-05-22T14:57:45+00:00

I have a file containing string like this one : print $hash_xml->{‘div’}{‘div’}{‘div’}[1]… I want

  • 0

I have a file containing string like this one :

print  $hash_xml->{'div'}{'div'}{'div'}[1]...

I want to replace {'div'}{'div'}{'div'}[1] by something else.

So I tried

%s/{'div'}{'div'}{'div'}[1]/by something else/gc

The strings were not found. I though I had to escape the {,},[ and ]

Still string not found.

So I tried to search a single { and it found them.
Then I tried to search {'div'}{'div'}{'div'} and it found it again.
Then {'div'}{'div'}{'div'}[1 was still found.

To find {'div'}{'div'}{'div'}[1]

I had to use %s/{'div'}{'div'}{'div'}[1\]

Why ?

vim 7.3 on Linux

  • 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-22T14:57:46+00:00Added an answer on May 22, 2026 at 2:57 pm

    That’s because the [ and ] characters are used to build the search pattern.

    See :h pattern and use the help file pattern.txt to try the following experiment:

    • Searching for the “[9-0]” pattern (without quotes) using /[0-9] will match every digit from 0 to 9 individually (see :h \[)

    • Now, if you try /\[0-9] or /[0-9\] you will match the whole pattern: a zero, an hyphen and a nine inside square brackets. That’s because when you escape one of [ or ] the operator [*] ceases to exist.

    Using your search pattern, /{'div'}{'div'}{'div'}[1\] and /{'div'}{'div'}{'div'}\[1] should match the same pattern which is the one you want, while /{'div'}{'div'}{'div'}[1] matches the string {'div'}{'div'}{'div'}1.

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

Sidebar

Related Questions

I have a console app containing an application configuration file containing one connection string
I have a data file containing a combination of doubles and strings like this:
I have a .plist file containing a dictionary item, something like this: <dict> <dict>
I have read several topics (like this one: Database field containing HTML display raw
I have a zip file containing a folder structure like main-folder/ subFolder1/ subFolder2/ subFolder3/
I have an ARFF file containing 14 numerical columns. I want to perform a
in the configuration file i have entries similar to this one: filepath = c:\Program
Suppose I have a string such as this in a text file: (((var1 AND
I have a file called something like FILE-1.txt or FILE-340.txt. I want to be
This should be really simple. If I have a String like this: ../Test?/sample*.txt then

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.