With regexp replace can you get the match and use it?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

With regexp replace can you get the match and use it?

Post by mydarkpassenger »

Is it possible with the XYPlorer regexp rename to take a match and use the match info in a rename. For example, I'd like to clean up the name of a bunch of files so that they are formatted slightly different, for example capitalize certain parts of a file like s01e02 Episode and make it S01E02 - Episode. Is there a way to do this?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: With regexp replace can you get the match and use it?

Post by bdeshi »

Yes. You capture a pattern with () and reuse the match using $1, $2 etc.
Here's an example of a regex pattern that reuses matched sections in $1 $2 $3

Code: Select all

s(\d+)e(\d+) (Episode.*) > S$1E$2 - $3
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Re: With regexp replace can you get the match and use it?

Post by mydarkpassenger »

Awesome thank you. Just wondering do you know if it's possible to recase the return data?

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: With regexp replace can you get the match and use it?

Post by bdeshi »

Sadly VB6 depends on VBScript for a RegExp engine, which doesn't support case modifiers, and XY is built with VB6. See http://www.xyplorer.com/xyfc/viewtopic.php?f=3&t=13507
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Re: With regexp replace can you get the match and use it?

Post by mydarkpassenger »

Surprised XYPlorer is still developed in VB6. It's such a limited language compared to most modern languages. I guess just too much work to move it to a new language.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: With regexp replace can you get the match and use it?

Post by bdeshi »

Actually VB6's own features (or lack of them) plays little part in XYplorer's development. don makes extensive direct use of the underlying Windows API functions.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

Post Reply