Jump to content

How to check if it's a valid Filename ?


mozart90
 Share

Recommended Posts

Hi,

I've got a string and I would like to use it as a file name. Unfortunatly there are often forbidden charaters in these strings like * or /.

(OS is win XP)

I didn't find anything to this topic in the forum.

I want to be sure to get a valid file name, so forbidden characters should be exchanged with a _ or something like that

Is there a UDF?

Is it clever to write this with regexp ?

Greetings mozart90

Edited by mozart90
Link to comment
Share on other sites

Hi,

Global $a = "theword.toCheck"
$return = StringRegExp($a, "^[A-Za-z0-9_ -\.]+$", 0)
If @error <> 0 Then MsgBox(64, "Something is wrong", "Damn :-)")
If $return Then
    MsgBox(64, "Info", "No bad char found")
Else
    MsgBox(16, "Info", "Bad char found")
EndIf

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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...