Ask a Question related to ASP.NET General, Design and Development.
-
Rajeev Soni #1
Regular Expression....?
Hi
I am looking for the regular expression for validating the allowed file types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the expression should not be case sensitive like it must match ZIP | zip | zIp.....
regards
rajeev
Rajeev Soni Guest
-
Regular Expression
Hi, I am writing a script that parses an html file (which has been retrieved as a scalar by LWP::UserAgent). The script looks for everything in... -
Regular expression help
Hi, I'm pretty new to regular expressions. Before, I used to write long-winded and buggy segments of code with PHPs string functions to extract... -
Regular expression for both first and last name?
I'm new to regular expressions, can someone explain to me how I can write one that will check for 2 names, at least, for a name field? Thanks!... -
help on regular expression
Hi, I need some help on regular expression... i have following in variable $total_count $total_count = "##I USBP 000001 10:38:09(000)... -
[PHP] REGULAR EXPRESSION HELP
John wrote: Your "newline" may be \r\n or \r instead of just \n. -- ---John Holmes... Amazon Wishlist:... -
Herve MAILLARD #2
Re: Regular Expression....?
Hi,
Have a look at this adress : [url]http://www.regexlib.com/Default.aspx[/url]
Regards,
H. MAILLARD
"Rajeev Soni" <rajeev_css@rediffmail.com> a écrit dans le message de news:
[email]OfPzU2FUDHA.2092@TK2MSFTNGP10.phx.gbl[/email]...
Hi
I am looking for the regular expression for validating the allowed file
types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the
expression should not be case sensitive like it must match ZIP | zip |
zIp.....
regards
rajeev
Herve MAILLARD Guest
-
Rajeev Soni #3
Re: Regular Expression....?
Hi,
i have this validationexpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT|doc|DOC)$"
but in the above case i need to repilcate each extension twice once in lower case and once in upper case and this expression will not accept file extension as ".TxT".
Is there any option in regular expression where we can specifiy to perform matching without considering the case of letter.
thanks
rajeev
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in message news:et0A8AGUDHA.1552@TK2MSFTNGP10.phx.gbl...
Hi
I have already been to that, i have regular expression which validates given file type... but it is case sensitive and i need to create validation expression by getting the allowed file types from DB. So the there may be any number of extensions.
Thanks
Rajeev
"Herve MAILLARD" <rvmaillard@free.fr> wrote in message news:3f1d4c12$0$1990$626a54ce@news.free.fr...> Hi,
>
> Have a look at this adress : [url]http://www.regexlib.com/Default.aspx[/url]
>
> Regards,
>
> H. MAILLARD
>
> "Rajeev Soni" <rajeev_css@rediffmail.com> a écrit dans le message de news:
> [email]OfPzU2FUDHA.2092@TK2MSFTNGP10.phx.gbl[/email]...
> Hi
>
> I am looking for the regular expression for validating the allowed file
> types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the
> expression should not be case sensitive like it must match ZIP | zip |
> zIp.....
>
> regards
> rajeev
>
>Rajeev Soni Guest
-
Elliot M. Rodriguez #4
Re: Regular Expression....?
Yes: use the i modifier:
/^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT|doc|DOC)$/i
--
Elliot M. Rodriguez, MCSD
*** It would take 227 cans of Mountain Dew to kill me***
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in message news:%238r74KGUDHA.2180@TK2MSFTNGP12.phx.gbl...
Hi,
i have this validationexpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT|doc|DOC)$"
but in the above case i need to repilcate each extension twice once in lower case and once in upper case and this expression will not accept file extension as ".TxT".
Is there any option in regular expression where we can specifiy to perform matching without considering the case of letter.
thanks
rajeev
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in message news:et0A8AGUDHA.1552@TK2MSFTNGP10.phx.gbl...
Hi
I have already been to that, i have regular expression which validates given file type... but it is case sensitive and i need to create validation expression by getting the allowed file types from DB. So the there may be any number of extensions.
Thanks
Rajeev
"Herve MAILLARD" <rvmaillard@free.fr> wrote in message news:3f1d4c12$0$1990$626a54ce@news.free.fr...> Hi,
>
> Have a look at this adress : [url]http://www.regexlib.com/Default.aspx[/url]
>
> Regards,
>
> H. MAILLARD
>
> "Rajeev Soni" <rajeev_css@rediffmail.com> a écrit dans le message de news:
> [email]OfPzU2FUDHA.2092@TK2MSFTNGP10.phx.gbl[/email]...
> Hi
>
> I am looking for the regular expression for validating the allowed file
> types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the
> expression should not be case sensitive like it must match ZIP | zip |
> zIp.....
>
> regards
> rajeev
>
>Elliot M. Rodriguez Guest
-
Rajeev Soni #5
Re: Regular Expression....?
Hi
Thanks for the response... but placing "/" at start and end with "i" doesnot work..... it is also not accepting txt/TXT/doc/DOC extensions.
I am using VS.NET 2003 with IE 6 sp1.
regards
rajeev
"Elliot M. Rodriguez" <sbsp@bis.com> wrote in message news:uyNeEQGUDHA.940@TK2MSFTNGP11.phx.gbl...
Yes: use the i modifier:
/^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT|doc|DOC)$/i
--
Elliot M. Rodriguez, MCSD
*** It would take 227 cans of Mountain Dew to kill me***
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in message news:%238r74KGUDHA.2180@TK2MSFTNGP12.phx.gbl...
Hi,
i have this validationexpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT|doc|DOC)$"
but in the above case i need to repilcate each extension twice once in lower case and once in upper case and this expression will not accept file extension as ".TxT".
Is there any option in regular expression where we can specifiy to perform matching without considering the case of letter.
thanks
rajeev
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in message news:et0A8AGUDHA.1552@TK2MSFTNGP10.phx.gbl...
Hi
I have already been to that, i have regular expression which validates given file type... but it is case sensitive and i need to create validation expression by getting the allowed file types from DB. So the there may be any number of extensions.
Thanks
Rajeev
"Herve MAILLARD" <rvmaillard@free.fr> wrote in message news:3f1d4c12$0$1990$626a54ce@news.free.fr...> Hi,
>
> Have a look at this adress : [url]http://www.regexlib.com/Default.aspx[/url]
>
> Regards,
>
> H. MAILLARD
>
> "Rajeev Soni" <rajeev_css@rediffmail.com> a écrit dans le message de news:
> [email]OfPzU2FUDHA.2092@TK2MSFTNGP10.phx.gbl[/email]...
> Hi
>
> I am looking for the regular expression for validating the allowed file
> types to upload like files like "zip,pdf,doc,rtf,gif,jpg,png,txt"; and the
> expression should not be case sensitive like it must match ZIP | zip |
> zIp.....
>
> regards
> rajeev
>
>Rajeev Soni Guest
-
Chris R. Timmons #6
Re: Regular Expression....?
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in
news:uEilzXGUDHA.1724@TK2MSFTNGP10.phx.gbl:
Rajeev,> Hi
>
> Thanks for the response... but placing "/" at start and end with
> "i" doesnot work..... it is also not accepting txt/TXT/doc/DOC
> extensions. I am using VS.NET 2003 with IE 6 sp1.
The /i modifier works in Perl, but not in .Net. To make a regex
case-insensitive in .Net, use the case-insensitive (?i) mode
modifier. It should be the first thing in the regex. For example:
(?i)^.*?\.(txt|zip|doc|exe)$
will match a string ending in .txt, .zip, .doc or .exe, regardless of
the string's case.
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
[url]http://www.crtimmonsinc.com/[/url]
Chris R. Timmons Guest
-
Rajeev Soni #7
Re: Regular Expression....?
Hi Chris,
placing "(?i)" at the start of expression also doesnot work, it gives me JavaScript Error "Syntax Error in regular expression".
i tried with both ways
ValidationExpression = "(?i)^.*?\.(txt|zip|doc|exe)$"
ValidationExpression = "(?i)^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+(?i)\.(txt|TXT|doc|DOC)$".
I am using
- WinXP Professional
- VS.NET 2003
- Framework 1.1
- IE6 with SP1
Thanks
Rajeev
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xns93C094F567DF0crtimmonscrtimmonsin@207.46.2 48.16...> "Rajeev Soni" <rajeev_css@rediffmail.com> wrote in
> news:uEilzXGUDHA.1724@TK2MSFTNGP10.phx.gbl:
>>> > Hi
> >
> > Thanks for the response... but placing "/" at start and end with
> > "i" doesnot work..... it is also not accepting txt/TXT/doc/DOC
> > extensions. I am using VS.NET 2003 with IE 6 sp1.
> Rajeev,
>
> The /i modifier works in Perl, but not in .Net. To make a regex
> case-insensitive in .Net, use the case-insensitive (?i) mode
> modifier. It should be the first thing in the regex. For example:
>
> (?i)^.*?\.(txt|zip|doc|exe)$
>
> will match a string ending in .txt, .zip, .doc or .exe, regardless of
> the string's case.
>
>
> Hope this helps.
>
> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> [url]http://www.crtimmonsinc.com/[/url]Rajeev Soni Guest
-
Chris R. Timmons #8
Re: Regular Expression....?
"Rajeev Soni" <rajeev_css@rediffmail.com> wrote in
news:u4zGCMNUDHA.1556@TK2MSFTNGP10.phx.gbl:
Rajeev,> Hi Chris,
> placing "(?i)" at the start of expression also doesnot work, it
> gives me JavaScript Error "Syntax Error in regular expression".
> i tried with both ways
> ValidationExpression = "(?i)^.*?\.(txt|zip|doc|exe)$"
> ValidationExpression =
> "(?i)^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w
> ]*))+(?i)\.(txt|TXT|doc|DOC)$".
>
> I am using
> - WinXP Professional
> - VS.NET 2003
> - Framework 1.1
> - IE6 with SP1
OK. I didn't know you were using JavaScript.
For client-side JavaScript in IE6, there are two different syntaxes
for regular expressions. They both work the same:
[url]http://msdn.microsoft.com/library/en-[/url]
us/script56/html/js56jsobjregexpression.asp
Here's an example:
<HTML>
<HEAD>
<TITLE>Case-Insensitive JavaScript Regular Expression</TITLE>
</HEAD>
<BODY>
<SCRIPT language="JavaScript">
<!--
function IsFilenameValid_Version1(filename)
{
// Regex syntax using a RegExp object.
var re = new RegExp("^.*?\\.(txt|zip|doc|exe)$", "i");
return filename.match(re);
}
function IsFilenameValid_Version2(filename)
{
// Regex syntax using the native regex type.
var re = /^.*?\\.(txt|zip|doc|exe)$/i;
return filename.match(re);
}
var filename1 = "c:\\folder\\filename.TXT";
var filename2 = "c:\\folder\\filename.ppt";
if (IsFilenameValid_Version1(filename1))
document.write(filename1 + " is valid.<BR>");
else
document.write(filename1 + " is not valid.<BR>");
if (IsFilenameValid_Version2(filename2))
document.write(filename2 + " is valid.<BR>");
else
document.write(filename2 + " is not valid.<BR>");
//-->
</SCRIPT>
</BODY>
</HTML>
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
[url]http://www.crtimmonsinc.com/[/url]
Chris R. Timmons Guest
-
Rajeev Soni #9
Re: Regular Expression....?
Thanks Chris,
i wrote Custom validator javascript function on to the client side usingbut> function IsFilenameValid_Version1(filename)thanks> function IsFilenameValid_Version2(filename) doesnot seem to work try and give it a valid file... it returns false.
rajeev
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:Xns93C15BB813F9Fcrtimmonscrtimmonsin@207.46.2 48.16...> "Rajeev Soni" <rajeev_css@rediffmail.com> wrote in
> news:u4zGCMNUDHA.1556@TK2MSFTNGP10.phx.gbl:
>>> > Hi Chris,
> > placing "(?i)" at the start of expression also doesnot work, it
> > gives me JavaScript Error "Syntax Error in regular expression".
> > i tried with both ways
> > ValidationExpression = "(?i)^.*?\.(txt|zip|doc|exe)$"
> > ValidationExpression =
> > "(?i)^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w
> > ]*))+(?i)\.(txt|TXT|doc|DOC)$".
> >
> > I am using
> > - WinXP Professional
> > - VS.NET 2003
> > - Framework 1.1
> > - IE6 with SP1
> Rajeev,
>
> OK. I didn't know you were using JavaScript.
>
> For client-side JavaScript in IE6, there are two different syntaxes
> for regular expressions. They both work the same:
>
> [url]http://msdn.microsoft.com/library/en-[/url]
> us/script56/html/js56jsobjregexpression.asp
>
> Here's an example:
>
>
> <HTML>
> <HEAD>
> <TITLE>Case-Insensitive JavaScript Regular Expression</TITLE>
> </HEAD>
> <BODY>
> <SCRIPT language="JavaScript">
> <!--
> function IsFilenameValid_Version1(filename)
> {
> // Regex syntax using a RegExp object.
> var re = new RegExp("^.*?\\.(txt|zip|doc|exe)$", "i");
> return filename.match(re);
> }
>
> function IsFilenameValid_Version2(filename)
> {
> // Regex syntax using the native regex type.
> var re = /^.*?\\.(txt|zip|doc|exe)$/i;
> return filename.match(re);
> }
>
> var filename1 = "c:\\folder\\filename.TXT";
> var filename2 = "c:\\folder\\filename.ppt";
>
> if (IsFilenameValid_Version1(filename1))
> document.write(filename1 + " is valid.<BR>");
> else
> document.write(filename1 + " is not valid.<BR>");
>
> if (IsFilenameValid_Version2(filename2))
> document.write(filename2 + " is valid.<BR>");
> else
> document.write(filename2 + " is not valid.<BR>");
>
> //-->
> </SCRIPT>
>
> </BODY>
> </HTML>
>
>
> Hope this helps.
>
> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> [url]http://www.crtimmonsinc.com/[/url]Rajeev Soni Guest



Reply With Quote

