Interesting problem with RegEx Replace - Rapid PHP 14.3

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.
  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;
Post Reply
DaveMorton
Posts: 28
Joined: Thu Apr 11, 2013 9:25 pm

Interesting problem with RegEx Replace - Rapid PHP 14.3

Post by DaveMorton »

Hi, all. Before I get into my issue, let me give you my specs:
  • OS: Windows 10 Professional, most recent build
  • IDE: Rapid PHP 2016 Version 14.3 (14.3.0.187)
Ok, here's what I'm seeing. If I do a RegEx search/replace for the pattern \_(\W) with the string *\1 it doesn't use the captured group, but instead uses literal \1 instead. However, if I put any character between the asterisk and \1 it works as expected. For example:
  • String to search: "TEST _ TEST"
  • Replacement Regex: \_(\W)
  • Replacement string: _\1
  • Result: "TEST *\1TEST"
  • String to search: "TEST _ TEST"
  • Replacement Regex: \_(\W)
  • Replacement string: _(\1
  • Result: "TEST *( TEST" <-- Please note the space
I haven't tried other RegEx patterns, but I've tried other replacement strings, and the only way I can get the captured group to appear instead of \1 is to place a character between the * and \1, and this is not desireable. The only workaround I've been able to find is to just do a simple (non-RegEx) search for just the underscore and make my replacements by hand. With hundreds of underscores to wade through in my text, in dozens of files, that can get a little tedious.
User avatar
pmk65
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Interesting problem with RegEx Replace - Rapid PHP 14.3

Post by pmk65 »

Im have written a plugin for doing RegEx Search & Replace, as the build-in RegEx Search & Replace is flawed.

If you are interested in testing it out, send me a PM.
There are 10 types of people in the world: Those who understand binary and those who don't.
Post Reply