Author Topic: Search and Replace with global doesn't work  (Read 190 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2433
  • Hero Points: 202
  • Text
Search and Replace with global doesn't work
« on: October 12, 2021, 11:50:54 pm »
With big find I do
SearchFor "$"
ReplaceWith " }},"
Use Perl Regex.
Replace.
On prompting, I enter N, N, Y, G
Skip the 1st two, replace the third and then it should replace all remaining.

It doesn't replace any of the remaining.


Hm.... "ReplaceAll" only replaces the first occurance.


If I change to:
SearchFor "(.)$"
ReplaceWith "\1 }},"

Then it works.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6127
  • Hero Points: 470
Re: Search and Replace with global doesn't work
« Reply #1 on: October 13, 2021, 02:05:58 am »
Reproduced. I suspect it has something to do with the search string being 0 length.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6127
  • Hero Points: 470
Re: Search and Replace with global doesn't work
« Reply #2 on: October 13, 2021, 03:03:10 am »
This problem does have to do with a zero length match. Your work around is a good solution.


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6127
  • Hero Points: 470
Re: Search and Replace with global doesn't work
« Reply #3 on: October 27, 2021, 12:49:22 am »