Jump to content

Recommended Posts

Posted

Hello,

I need to match in regex if a filename have month and year. Example

my_business_03_2020

03 my business 2020

And so on. So i need to match if there are two digit consecutive and four digit consecutive and extract from the file name. I need both, if exist one of the two is considerated "error" for me

Thanks ;)

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Posted (edited)

Hi ahmet. Thanks for your help

I need to get the month and the date from the file

[0]=03

[1]=2020

I have try to change the RegEx flag to 3 but not work, return all the string

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Posted
$sTestString="my_business_032020"
$btest=StringRegExp($sTestString,".*(\d\d).*(\d\d\d\d)",1)
if IsArray($btest) Then
    $month = $btest[0]
    $year = $btest[1]
    MsgBox(0,"Test", "Month: " & $month & @CRLF & "Year: " & $year)
Else
    ; error
EndIf

Based on the example from ahmet :)

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...