Re: Regular Expressions

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Use this following expression : $(?<!\.(?:exe|vbs))
It means that you want a string finishing by something that is not a '.'
character followed by exe or vbs.
Explanations :
$ it's the end of the line or string
(?<! it's the backreference to say that you are looking backward for
something you do not want
\. it's the '.' character
(?: it's a non capturing block that permit the choice between exe
and vbs
exe it's the first extension to check
| it's the separator of the two extensions
vbs it's the second extension to check
) it's the end of the non capturing block
) it's the end of the backtracking

The following line will tell you if the file DOES NOT end with .exe or .vbs
:
Regex.IsMatch(maChaine,@"$(?<!\.(?:exe|vbs))")

Hope it helps,

Ludovic SOEUR.


"Singularity.co.uk" <Brendan.Collins@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> a écrit
dans le message de news:Owjre5yoFHA.1048@xxxxxxxxxxxxxxxxxxxxxxx
> Hi
>
> Does anyone have or know of a regular expression for preventing users from
> browsing to and selecting an .exe or .vbs file in a file type form object?
>
> If not, are there any good tutorials or articles that may be of benefit?
>
> I don't want users to be able to upload these types of files to my site.
>
> Thanks
>
> Brendan
>
>


.



Relevant Pages

  • Re: Microsoft and Trust Take 2
    ... running anti-virus tries to run a .vbs file, ... The same operation with a .exe is allowed. ... most people don't use VBS. ... flash in their email? ...
    (microsoft.public.vb.general.discussion)
  • File Download dialog box appears when run program from network dri
    ... I have Windows Server 2003 EE installed and need to run some EXE and VBS ... "File Download" dialog box appears and the "Always ask before opening this ...
    (microsoft.public.windows.server.general)
  • Re: Explorer/Internet Explorer menu missing
    ... Restore Missing Toolbars EXE or VBS ... >> Most folks do not empty their Temporary Internet Files folder often ... >> Best to do this with all instances of Internet Explorer closed. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: vbs to exe
    ... wait i password for the command runas -.-" while if i run this ... in .vbs: wscript xxxx.vbs it work... ... mode.....when i run the exe i see the window that question me the ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Adding two numbers does not work
    ... This is a syntax error that VBS will pick up, if there is no error handler. ... the type of error that Ray pointed out. ... data is delivered as a numeric string. ... but not if both are string subtypes. ...
    (microsoft.public.scripting.vbscript)