anilmuthineni / foxreplace

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

Replace Start and end with single substitution #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,
i really like your plugin and want to know if there is away to replace the 
start and end of phrase without changing the text in the middle

For example :
https://code.google.com/p/foxreplace/issues/entry

replace "https://code" and "entry" with another word ;

www.google.com/p/foxreplace/issues/list

on plugin substitution the sholud be 1 substition line instead of 2

thanks

Original issue reported on code.google.com by marshall...@gmail.com on 27 Jun 2015 at 10:09

GoogleCodeExporter commented 9 years ago
Yes, you can use a regular expression like this:

Replace: https://code(\.google\.com/p/foxreplace/issues/)entry
With: www$1list

Note that you have to use a backslash before the dot because it's a special 
character in the RegExp syntax. And $1 in the output means the text matched in 
the first parenthesis. So, in general, you can use this pattern: 
start(middle)end -> newStart$1newEnd.

More info on regular expressions: 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
/RegExp#Special_characters_meaning_in_regular_expressions

Original comment by marc.r...@gmail.com on 28 Jun 2015 at 5:18

GoogleCodeExporter commented 9 years ago
Hello thanks for your reply and accepting the request.

Can this be done with phrases,links where part of it is different

For example
https://code.google.com/p/foxreplace/issues/entry
https://code.google.com/p/foxreplace/bang/entry

Replace: https://code(\.google\.com/p/foxreplace/*/)entry
With: www$1list

where using "*" as a wildcard .

AQnd is this function already available or i need to wait for you to implement 
in the addon
(not being impatient ,just want to know)
Thanks

Original comment by marshall...@gmail.com on 29 Jun 2015 at 12:32

GoogleCodeExporter commented 9 years ago
This is already implemented. You can't use "*" as a wildcard, you have to use 
".*" instead, where "." means "any character" and "*" means "the previous item 
0 or more times". You can also use ".+", where "+" means "the previous item 1 
or more times".

Original comment by marc.r...@gmail.com on 29 Jun 2015 at 4:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Does it need to be like this
http://i.imgur.com/JZshi6u.jpg

because when replacing getting this

From http://i.imgur.com/ZmWiFtG.jpg  to http://i.imgur.com/KPFEehM.jpg

Original comment by marshall...@gmail.com on 29 Jun 2015 at 7:35

GoogleCodeExporter commented 9 years ago
I'm not sure that I understand your last comment, but it has to be like this: 
https://code(\.google\.com/p/foxreplace/.*/)entry (note that there's ".*" 
instead of "*"). Also you have to choose the type "Regular Expression" instead 
of "Text" (click on the button with the "T" to the left of the "Replace" field).

Original comment by marc.r...@gmail.com on 30 Jun 2015 at 8:07

GoogleCodeExporter commented 9 years ago
Thanks problem solve 
didn't knew there was this option (Regular Expression)

Original comment by marshall...@gmail.com on 30 Jun 2015 at 11:54