Jump to content
Sign in to follow this  

regular expression.... y u no express!!

Recommended Posts


OK, so first off I know I'm not very good at this.   I'm trying to make a pair of regular expressions.   One to grab the filename from a filepath and one to grab the extension from the filepath.  I know about _PathSplit but just thought I'd give this a try.

Example filepath that isn't working for me is:


I'm using regular expression:


It's failing because there are full stops (periods) in the path and I'm a bit lost how to do it.  I tried ([\w|\.]+) which resulted in deafening silence.  Any help appreciated.

Share this post

Link to post
Share on other sites
2 hours ago, gruntydatsun said:

I know I'm not very good at this

Don't worry you're not alone! I am also pretty bad at regular expressions but since I'm willing to learn more on the topic I gave it a try anyways.

#include <Array.au3>
#include <StringConstants.au3>

$sTest = "C:\SharedData\CAT\v1.5.23\Back_2.7.2_Test.html"
$sPattern = "(.*\\)(.*)\.(\w{1,4})$"

$aMatches = StringRegExp($sTest, $sPattern, $STR_REGEXPARRAYGLOBALMATCH)

There's probably a better way to do it but it seems to work for me.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.