Page 1 of 1

Request for a Regex

Posted: 09 Jan 2015 15:23
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 ...

Re: Request for a Regex

Posted: 09 Jan 2015 15:33
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.

Re: Request for a Regex

Posted: 09 Jan 2015 15:36
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;

Re: Request for a Regex

Posted: 09 Jan 2015 15:37
by aliteralmind
Right. I only supplied the regex, not the "do this for all selected files" part.

Re: Request for a Regex

Posted: 09 Jan 2015 16:10
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:

Re: Request for a Regex

Posted: 09 Jan 2015 16:10
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

Re: Request for a Regex

Posted: 09 Jan 2015 16:34
by aliteralmind
That's me :biggrin:

This is the article I contributed: Using regular expressions to validate a numeric range

Re: Request for a Regex

Posted: 09 Jan 2015 16:36
by Marco
A little addendum: you may want to perform a recase("string", "removediacritics") first, otherwise vowels like à or é won't be removed.