Request for a Regex

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Request for a Regex

Post by aurumdigitus »

Would someone be kind enough to furnish a Regex to be used in a script that will do the following:

For the selected file(s) remove all vowels from the Name but leave the Extension untouched.

Thank you yet again ...

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

Re: Request for a Regex

Post by aliteralmind »

Code: Select all

$nameExt = "astuhosetuhahcsotetoasuh.abc";
   $base = getpathcomponent($nameExt, "base");
   $ext = getpathcomponent($nameExt, "ext");
   echo RegExReplace($base, "[aeiou]", "").".".$ext;
And check out the Stack Overflow Regular Expressions FAQ, which I maintain. In particular, the bottom section has great online and offline tools for analyzing and creating regexes.
Windows 8.1, 64-bit

highend
Posts: 14946
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Request for a Regex

Post by highend »

That's a two step process.

Code: Select all

    $list = "";
    foreach($file, "<get SelectedItemsPathNames |>") {
        $base = regexreplace(getpathcomponent($file, "base"), "[aeiou]");
        $ext  = getpathcomponent($file, "ext");
        $file = "$base.$ext";
        $list = $list . $file . "<crlf>";
    }

    text $list;
One of my scripts helped you out? Please donate via Paypal

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

Re: Request for a Regex

Post by aliteralmind »

Right. I only supplied the regex, not the "do this for all selected files" part.
Windows 8.1, 64-bit

aurumdigitus
Posts: 1075
Joined: 30 May 2008 21:02
Location: Lake Erie

Re: Request for a Regex

Post by aurumdigitus »

Copious thank you's everyone. The code is exactly what was needed and it came so quickly!

Scoping out the reference to stackoverflow it looks very promising. The time may have finally come to "get my feet wet" in the pool of Regex. :appl:

Filehero
Posts: 2731
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Request for a Regex

Post by Filehero »

aliteralmind wrote:And check out the Stack Overflow Regular Expressions FAQ, which I maintain.
Saves me a question. Cool, that the maintainer actually is really you. :tup:

Cheers, FH

aliteralmind
Posts: 261
Joined: 02 Dec 2014 16:49

Re: Request for a Regex

Post by aliteralmind »

That's me :biggrin:

This is the article I contributed: Using regular expressions to validate a numeric range
Windows 8.1, 64-bit

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

Re: Request for a Regex

Post by Marco »

A little addendum: you may want to perform a recase("string", "removediacritics") first, otherwise vowels like à or é won't be removed.
Tag Backup - SimpleUpdater - XYplorer Messenger - The Unofficial XYplorer Archive - Everything in XYplorer
Don sees all [cit. from viewtopic.php?p=124094#p124094]

Post Reply