Jump to content

[Solved] StringRegExp help


Recommended Posts

$fFile = "X:\Folder\Archive.part1.rar"
ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)\.rar", "$1")&@CR) ;Works fine
ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)?\.rar", "$1")&@CR);keeps "part1"

I want to set the ".part1" section may or may not appear. I thought this is the correct syntax, but It doesn't works.

Edited by Izebize
Link to comment
Share on other sites

Thanks for your help!

I used StringInStr as you suggested, but now I figured out how to make it work with RegExp:

$fFile = "X:\Folder\Archive.part1.rar"
ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*)(?:\.part1)\.rar", "$1")   &@CR);Old one
ConsoleWrite(StringRegExpReplace($fFile, ".*\\(.*?)(?:\.part1)?\.rar", "$1") &@CR);Working one
"?" is very important in these cases.
Link to comment
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
 Share

  • Recently Browsing   0 members

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