rickysarraf / foxreplace

Automatically exported from code.google.com/p/foxreplace
0 stars 0 forks source link

Feedback (\1) not working for replace #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. enter in search something and and mark place to go into memory #1 with 
brackets () eg "/video/(\d+)/[^"]+" for text "/video/12345/hello"
2. enter in replace \1 - so it should replace whole found string with numbers 
(\d+) inside it
3. it doesn't

What is the expected output? What do you see instead?

expected output: 12345
we see instead : \1

What version of the product are you using? On what operating system?
0.12.2
WIN XP SP3

Please provide any additional information below.

please fix it ^_^ becouse without it it's a pain in you know what sometimesto 
replace what you need

Original issue reported on code.google.com by OwynTyler on 25 Sep 2010 at 11:31

GoogleCodeExporter commented 9 years ago
It's strange, because I have tried it a lot of times and has always worked. But 
I will try it with your example and tell you if I can reproduce the problem.

Original comment by marc.r...@gmail.com on 25 Sep 2010 at 2:51

GoogleCodeExporter commented 9 years ago
any luck? here's my exported settings with the bug

Original comment by OwynTyler on 11 Oct 2010 at 10:51

Attachments:

GoogleCodeExporter commented 9 years ago
Hi, now I have discovered what the problem is.

Short answer: use $1 instead of \1.

Long answer: \1 references memory #1 in the RegExp (the input); for example, 
"/video/(\d+)/[^"]+/\1" would match "/video/12345/hello/12345". But to 
reference memory #1 in the output you have to use $1 instead.

Original comment by marc.r...@gmail.com on 13 Oct 2010 at 11:03

GoogleCodeExporter commented 9 years ago
>>Status: Invalid

i use "\1" in notepad+ regex search and it works, i look at wikipedia and find 
"\1" not anything like "$1".

$1 worked in foxreplace, but why did you make $1 in it but not \1 like the 
standart says?
http://www.regular-expressions.info/brackets.html
http://www.explainth.at/en/re/backref.shtml

Original comment by OwynTyler on 13 Oct 2010 at 12:15

GoogleCodeExporter commented 9 years ago
\1 is the standard for *matching* a backreference, but not for using it in a 
replace operation. From your first link (in "How to Use Backreferences"): 

"The replacement text will use a special syntax to allow text matched by 
capturing groups to be reinserted. This syntax differs greatly between various 
tools and languages, far more than the regex syntax does."

I have just used the JavaScript syntax because it is what I can use. 
Specifically, the substitutions are done with String.replace(), and these are 
the special characters in the output:

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/repl
ace#Specifying_a_string_as_a_parameter

Original comment by marc.r...@gmail.com on 13 Oct 2010 at 3:07

GoogleCodeExporter commented 9 years ago
weird but like i said it works in replace field in notepad+ regex search & 
Replace and in manuals that i gave you there were nothing about dollar param 
"$1"

Original comment by OwynTyler on 13 Oct 2010 at 5:59

GoogleCodeExporter commented 9 years ago
In fact, if you follow one of the links in your first link, the one that says 
"replacement text reference" ( 
http://www.regular-expressions.info/refreplace.html ), you will see a big table 
with the RegExp syntax for several languages/platforms. There you can see that 
the backreference using $n is used in .NET, Java, Perl, ECMA (this includes 
JavaScript), and others.

Original comment by marc.r...@gmail.com on 13 Oct 2010 at 8:46

GoogleCodeExporter commented 9 years ago
oh now i see it's language program written in very dependant, thx.

Original comment by OwynTyler on 14 Oct 2010 at 8:08