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

Replace URLs (Regex issue)

Goto Page: 1 2 Next

#1 Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-04 14:57 | IP: IP Logged

I need regex REPLACE

https:\/\/(.*)\.website\.net/(.*)/(.*)/XXX/audios/(.*)/index.m3u8?extra=(.*)/(.*).m3u8

Replace with:

https:\/\/(.*)\.website\.net/(.*)/(.*)/audios/(.*).mp3?extra=(.*)/(.*).mp3

XXX: Remove
Black: Replace

Edited 2 time(s). Last edit at 2019-04-04 14:58 by maki.

Options: Reply | Quote | Up ^


#2 Re: Replace URLs (Regex issue)

Posted by: pspad | Date: 2019-04-04 15:20 | IP: IP Logged

You can't use regular expression in replace. Learn how to use substitute groups in replace. Regular expression manual with examples is available in the PSPad help and as I remember, you told you read the help from first to last letter.

Options: Reply | Quote | Up ^


#3 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-04 15:36 | IP: IP Logged

Quote:
You can't use regular expression in replace.

Can change some, for example, \1 or $1 or $2 etc. (regex) Escape Special Character

The help file requires learning from basic, and I'm lazy. Unfortunately, I have no knowledge how to replace in URLs.
I could change it manually, but I am looking for a pattern for automatic detection (Link Crawler) of URLs and changes.

Edited 2 time(s). Last edit at 2019-04-04 15:42 by maki.

Options: Reply | Quote | Up ^


#4 Re: Replace URLs (Regex issue)

Posted by: vbr | Date: 2019-04-04 17:55 | IP: IP Logged

Hi,
you can enclose the parts of the text, which should be manipulated for replacement with parens and resore these mached groups in the replacement pattern with numbered parts: $1
cf. the simplified example:

input text:
ABCD1234EFGH/XXX/IJKLMN/file.abc

search (re):
^(.*?)/XXX/(.*?)/(file\.)(abc)$

replace with
$1/$2/$3txt

resulting text after replacement:
ABCD1234EFGH/IJKLMN/file.txt

I guess it should be possible to adapt this patterns to match your specific data.

hth,
vbr

Options: Reply | Quote | Up ^


#5 Re: Replace URLs (Regex issue)

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

My regex is wrong anyway!

https:\/\/[a-z0-9]+\.audio\.net+/[a-z0-9]+/[a-z0-9]+/[a-z0-9]/audios/(.*?)/(.*?)/index\.m3u8?extra=(.*?)/(.*?)(m3u8\.)(mp3)$

\1\2\3

Edited 2 time(s). Last edit at 2019-04-04 19:18 by maki.

Options: Reply | Quote | Up ^


#6 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-05 18:52 | IP: IP Logged

@vbr - It seems to be more complicated than I thought, it must be according to this formula:
Example:

with
"pattern" : "pattern"
you specify the pattern that matches the rule

you can specify max depth (how deep the same rule can go)
"maxDecryptDepth" : 0

you can specify name (for yourself or when you share rules)
"name" : "Test"

you can specify pattern (DEEPDECRYPT) that returns the name of the package for all found links
"packageNamePattern" : "pattern"

you can specify pattern (SUBMITFORM) that selects the form to submit
"formPattern" : "pattern"

you can specify pattern (DEEPDECRYPT) that returns inner links/html to parse
"deepPattern" : "pattern"

you can specify pattern (REWRITE) to rewrite URL ($1 is first match, $2 is second match...)
"rewriteReplaceWith" : "$1"

Options: Reply | Quote | Up ^


#7 Re: Replace URLs (Regex issue)

Posted by: vbr | Date: 2019-04-06 07:00 | IP: IP Logged

Well,
as you might see, this is mostly unrelated to regex and certainly not relevant to PSPad; however, you may ask such questions in an appropriate forum, as suggested there:
board.jdownloader.org
hth,
vbr

Options: Reply | Quote | Up ^


#8 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-06 09:34 | IP: IP Logged

vbr - However, I only need regular expressions (match to link and rewrite), other things I know how to do.
And regular expressions are part of PSPad. Is not it?smiling smiley

Options: Reply | Quote | Up ^


#9 Re: Replace URLs (Regex issue)

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

Ok, in that case the quoted parts from the documentation are not relevant. But especially, the requirements for stable parts of the links and those needing replacement are not clear.
it seems in your samples, that the parentheses capture actually the parts to be discarded, you
Basically you need to capture the needed parts of the matched string to parens and recombine them in the replacement pattern, e.g.:
(http://starting_part.*?of_an_url/)useles/part_.*?thereof/(useful_numbered_part_[0-9]+)

replace with:

$1replacement_for_the_middle_part/$2

For referencing the captured groups (matched inside of parens) the metacharacters $ folowed by a number are used in the replacement pattern - in PSPad and apparently in your crawler tool too.
Other variants of regular expression engines use \ followed by a number here, which also appears in your samples.

hth,
vbr

Options: Reply | Quote | Up ^


#10 Re: Replace URLs (Regex issue)

Posted by: maki | Date: 2019-04-06 16:50 | IP: IP Logged

A very understandable explanation!!!

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

Regex only for translation !!!
This does not mean changes !!!

Replace with:
https:\/\/psv4\.website\.net/c(\d+)/u(\d+)/audios/[0-9a-z].mp3?extra=AnyCharacter\.mp3
EXAMPLE:
hXXps://psv4.website.net/c123865/u8764308/audios/a875gb76.mp3?extra=bGAWS2E72E2ED6%acd6#-_786xhjssdccr3r4v..mp3

Real Replace with:..........?

Now is born asking how to change it?

Edited 10 time(s). Last edit at 2019-04-06 16:56 by maki.

Options: Reply | Quote | Up ^


Goto Page: 1 2 Next





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