EditPad regex Help

What other productivity software are you working with...
Post Reply
SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

EditPad regex Help

Post by SkyFrontier »

Hi again.

How do I regex a filename so the files themselves are erased leaving paths only behind, with trailing '\'s? TIA!

As a general rule, the rightmost element of the last '\' can be considered as a file, even if it's lacking any extension or it's actually a folder.

Inputs:
c:\my\path\file.exe
d\another\random\path\_item

Outputs:
c:\my\path\
d\another\random\path\
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: EditPad regex Help

Post by Marco »

Code: Select all

^.*\\(?=.*?$)
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: EditPad regex Help

Post by SkyFrontier »

Hi, Marco, thanks for popping out.

It's producing the opposite, ie, taking out the paths, leaving the files behind.

Tried

Code: Select all

(^.*\\)?=.*?$
just to have some random mess.


In a variant task, I'd need to have just the parent folders as outputs. Please?
Inputs:
c:\my\path\file.exe
d\another\random\another path\_item

Outputs:
path
another path

Regards - and congrats for the awesome Archive!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: EditPad regex Help

Post by Marco »

SkyFrontier wrote: It's producing the opposite, ie, taking out the paths, leaving the files behind.
So you don't want to match the paths, you want to replace with nothing (aka remove) the files? Subtle difference :ninja: ... With the regex I gave you then you could click on "Copy matches" to have those paths. If you want to zap instead the filenames, then use this

Code: Select all

[^\\]*?$
, leaving the Replace box empty.

For the other task, use this

Code: Select all

(?<=^.*\\)[^\\]+?(?=\\[^\\]+?$)
to match the parent folders. Choose this route, instead of deleting the rest.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: EditPad regex Help

Post by SkyFrontier »

Hi, Marco. First task done.

But again - the other code is matching parent folders, thus replacing them by nothing; I need the other way round! :titter:

See...?

Code: Select all

Inputs:
c:\my\path\file.exe
d\another\random\another path\_item

Outputs:
path
another path
...or is it something I should change in replacement GUI I am missing...?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Marco
Posts: 2347
Joined: 27 Jun 2011 15:20

Re: EditPad regex Help

Post by Marco »

I told you that that regex matches the parent folders! I don't understand, if you need the parent folders, why you insist on deleting the rest? Copy the matches!
Attachments
Appunti-20180930-01.png
Appunti-20180930-01.png (157.52 KiB) Viewed 6162 times
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: EditPad regex Help

Post by SkyFrontier »

...didn't know I could do it that way, sorry... :roll:
Old dog got a new trick, thanks!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: EditPad regex Help

Post by SkyFrontier »

Downside of this method: way too slow compared to the regular '-del-right-on-the-document', when exporting to the clipboard from a 200 MB source file.

...waaaaaaaay too slow.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Post Reply