You are here: PSPad forum > English discussion forum > Need help on Replacement Expression
Posted by: maki | Date: 2020-03-31 09:48 | IP: IP Logged
Need help on Replacement Expression
I need help for "Back Reference" results
URL Match:
\.ru/(20[01][0-9]|2020)/0*([1-9]|1[0-2])/(\d+[-/]\d+)
Sub-Folder Name:
Replace with:???
number_number_number_number
AND
number_number_number-number
Edited 3 time(s). Last edit at 2020-03-31 09:53 by maki.
Posted by: pspad | Date: 2020-03-31 10:08 | IP: IP Logged
Each group is enclosed into ()
(group1)(group2)(group3)
in the result you can use reference to groups using $1...$n
e.g. I have number 123 and I want in the result 231
search: (\d)(\d)(\d)
replace: $2$3$1
Posted by: maki | Date: 2020-03-31 11:05 | IP: IP Logged
Example How to use pattern
My regex:
\.ru/([^/]+)/([^&\?/]+)
Replace:
[#1]_[#2]
result:
1234_1234
Correct!
Test:
\.ru/((20[01][0-9]|2020))/(0*([1-9]|1[0-2]))/((\d+[-/]\d+))
[#2]_[#3]_[#5]
Result:
2018_01
2018_01_20/1976
Invalid result
Edited 2 time(s). Last edit at 2020-03-31 11:08 by maki.
Posted by: pspad | Date: 2020-03-31 11:08 | IP: IP Logged
maki:Test:
[#2]_[#3]_[#5]Result:
2018_01
2018_01_20/1976Invalid result
When you will write your request to be understable, you will get answer.
Sorry, but this one isn't
Real search line example, real result you want is good start.
Posted by: maki | Date: 2020-03-31 11:28 | IP: IP Logged
\0
Indicates a back reference to the entire regular expression.
\1 - \9
Indicates a back reference a back reference is a reference to a previous sub-expression
$10, $11, $12, ...
Indicates a back reference more than 9
I use all combinations, and this is incorrect:
But it returns the wrong result.
Posted by: pspad | Date: 2020-03-31 11:43 | IP: IP Logged
Read my first answer and use it. It works.
Posted by: maki | Date: 2020-03-31 11:55 | IP: IP Logged
Url contains:
\.ru/(.*?)/(.*?)(?:$|\?|#).*
...then set:
Filename: \1_\2
Use:
\ or $
This is valid conditions match, but not for all applications
ht_p://website:/2020/10/234/3454
ht_p://website:/2020/10/234-3454
Filename Result:
2020_10_234_3454
AND
2020_10_234-3454
Edited 1 time(s). Last edit at 2020-03-31 11:56 by maki.
Posted by: maki | Date: 2020-03-31 14:29 | IP: IP Logged
Your pattern is extremely simple. I understand that.
But my pattern is not of the type "Expert":
I have 3 choices:
"Basic"
"Advanced"
and "Expert"
Ask for "Expert"
Edited 2 time(s). Last edit at 2020-03-31 14:30 by maki.
Posted by: pspad | Date: 2020-03-31 14:54 | IP: IP Logged
In your expression create groups using () and use substitution.
What don't you understand?
Posted by: maki | Date: 2020-03-31 15:00 | IP: IP Logged
My target file are named: URL for file name
so your examples don't match any url!
"/"
is an illegal character in the name so replace "_"
I am asking for a template for the addresses I gave at the beginning of the post.
Edited 2 time(s). Last edit at 2020-03-31 15:03 by maki.
Editor PSPad - freeware editor, © 2001 - 2023 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR