Regex on file name

HI, i use the following code to check if invalid character is on the file name and when i test it with file name consist / or @, i got myMatch=nil and does not give me an error…

    DIM tmp as string
    DIM rg AS New RegEx
    DIM myMatch AS RegExMatch
    rg.SearchPattern=" [^/\\.,!@#$%]*"
    tmp=REPLACE(replace(item.name,".jpg",""),".JPG","")
    myMatch=rg.search(tmp )
    if myMatch <> Nil then
      msgbox "Invalid characters in [" + tmp + "]"
    END IF

Your pattern is looking for a space followed by a character not between the brackets. I think you’re needing a pattern like:

[\\s/.,!@#$%]

which looks for something inside the brackets.

let me try… and i let u know…

thanks…got it working now

Have a look at RegExRX, it was a tremendous help with creating the module that turns blocks into inline css for HTML Edit. I feel less intimidated by RegEx now because of it :slight_smile:

Thanks Tim