You are here: PSPad forum > English discussion forum > Replace URLs (Regex issue)

Replace URLs (Regex issue)

Goto Page: Previous1 2

#11 Re: Replace URLs (Regex issue)

Posted by: vbr | Date: 2019-04-06 18:29 | IP: IP Logged

I fear, it still wasn't as understandable as was needed.
The samples are not quite consistent , but if you needed to remove the DELETE/ part, the pattern might be
(https://psv4\.website\.net/c\d+/u\d+/)DELETE/(audios/[0-9a-z]+\.mp3\?extra=.*?\.mp3)

replace with:
$1$2

If more replacements or deletions are needed, put more parenthesised groups to the pattern (and to the replacement as well $3 etc.).

(Also the question mark ? needs to be escaped as \? , on the other hand the slash shouldn't need escaping, but sometimes it might be appropriate too, e.g. in javascript source.)

hth,
vbr

Edited 1 time(s). Last edit at 2019-04-06 18:30 by vbr.

Options: Reply | Quote | Up ^


#12 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-06 18:55 | IP: IP Logged

Not work:

Cannot find: Wrong Regex

Options: Reply | Quote | Up ^


#13 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-06 19:12 | IP: IP Logged

Totally does not match the other part of the link, completely wrong regular expression!

Example 1:

h..ps://psv4.website.net/c813437/u484896533/69c971a8647/audios/a0f19061e74d/index.m3u8?extra=c70d5eXkAiml5v84bnHhoAMmFUuy4aH3z1Amj205AdYZnBqnSqKu8MuX7ioPQhhW6PRWYfM3ToRpkph5Jvegx7SMEsiU9eRVwFBz-IcIB0bVpVuULrAUv_PwCLaM00jv5Al8Xs4gIguMeXmi5dmEs5oQ8A#FILENAME/Doctor%20H%20-%20S.mp3.m3u8

Example 2:

h..ps://psv4.website.net/c813437/u484896533/69c971a8647/audios/a0f19061e74d/index.m3u8?extra=c70d5eXkAiml5v84bnHhoAMmFUuy4aH3z1Amj205AdYZnBqnSqKu8MuX7ioPQhhW6PRWYfM3ToRpkph5Jvegx7SMEsiU9eRVwFBz-IcIB0bVpVuULrAUv_PwCLaM00jv5Al8Xs4gIguMeXmi5dmEs5oQ8A#FILENAME/Doctor%20H%20-%20S.m3u8

Example 1:
Replace with:
h..ps://psv4.website.net/c813437/u484896533/audios/a0f19061e74d.mp3?extra=c70d5eXkAiml5v84bnHhoAMmFUuy4aH3z1Amj205AdYZnBqnSqKu8MuX7ioPQhhW6PRWYfM3ToRpkph5Jvegx7SMEsiU9eRVwFBz-IcIB0bVpVuULrAUv_PwCLaM00jv5Al8Xs4gIguMeXmi5dmEs5oQ8A#FILENAME/Doctor%20H%20-%20S.mp3.mp3

Example 2:
h..ps://psv4.website.net/c813437/u484896533/audios/a0f19061e74d.mp3?extra=c70d5eXkAiml5v84bnHhoAMmFUuy4aH3z1Amj205AdYZnBqnSqKu8MuX7ioPQhhW6PRWYfM3ToRpkph5Jvegx7SMEsiU9eRVwFBz-IcIB0bVpVuULrAUv_PwCLaM00jv5Al8Xs4gIguMeXmi5dmEs5oQ8A#FILENAME/Doctor%20H%20-%20S.mp3

69c971a8647 => DELETE [a-z0-9] (any letters/any numbers mixed)
/index.m3u8 => REPLACE WITH .mp3
.m3u8 => REPLACE WITH .mp3 (end line URL)

Edited 5 time(s). Last edit at 2019-04-06 19:22 by maki.

Options: Reply | Quote | Up ^


#14 Re: Replace URLs (Regex issue)

Posted by: vbr | Date: 2019-04-06 21:16 | IP: IP Logged

Ok, now the requirements are a lot clearer,
for the mentioned samples, the following pattern might work:

(https://psv4\.website\.net/c\d+/u\d+/)[0-9a-z]+/(audios/[0-9a-z]+)/index\.m3u8(\?extra=.*?\.)m3u8

replace with

$1$2.mp3$3mp3

(Asuming, there are no other cornercases, or lacking specification - e.g. the duplicated .mp3 in the first example looks strange.)

hth,
vbr

Options: Reply | Quote | Up ^


#15 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-06 21:37 | IP: IP Logged

@vbr - The pattern works correctly. smiling smiley
And when it comes to double mp3 etc. it just happens in some names [and it's not an extension) (depending on how the user's name file will be saved)

Options: Reply | Quote | Up ^


Goto Page: Previous1 2





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR