Re: Regular Expressions
- From: "Ludovic SOEUR" <Ludovic_SOEUR@xxxxxxxxxxx>
- Date: Mon, 22 Aug 2005 11:40:39 +0200
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
>
>
.
- References:
- Regular Expressions
- From: Singularity.co.uk
- Regular Expressions
- Prev by Date: Re: Single rescource file in a project?
- Next by Date: dotnet remoting datatable compression issue
- Previous by thread: Re: Regular Expressions
- Next by thread: Regular Expressions
- Index(es):
Relevant Pages
|