Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > case INsensitive regular expressions

Reply
Thread Tools

case INsensitive regular expressions

 
 
sabinosa
Guest
Posts: n/a
 
      10-21-2004
Hi everyone,
I am working with a RegularExpressionValidator in Visual Studio.NET.
I would like to define a custom regular expression that ignores the
letter case and therefore is case INsensitive. I have seen that the
syntax might be something like "(?i)" or "/i". However, when I try to
use that as part of my regular expression (ex. (?i)^(CSV|ZIP|TXT)$)
the result is a javascript error. The error says: "Syntax error in
regular expression"
(^(CSV|ZIP|TXT)$/i does not work)

Any idea what I am doing wrong? Thanks in advance for your responses!
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      10-21-2004

[ Followups set ]


sabinosa <(E-Mail Removed)> wrote:

> I am working with a RegularExpressionValidator in Visual Studio.NET.


> Any idea what I am doing wrong?



Posting a question that is not related to Perl into the Perl newsgroup.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      10-22-2004
sabinosa wrote:
> I am working with a RegularExpressionValidator in Visual Studio.NET.


Interesting! I didn't know that Visual Studio.NET supports Perl. I guess
there is always something new to learn.

> I would like to define a custom regular expression that ignores the
> letter case and therefore is case INsensitive. I have seen that the
> syntax might be something like "(?i)" or "/i".


Why don't you check the readily available documentation?

From "perldoc perlre":
Matching operations can have various modifiers. Modifiers that relate to
the interpretation of the regular expression inside are listed below.
Modifiers that alter the way a regular expression is used by Perl are
detailed in the section on "Regexp Quote-Like Operators" in the perlop
manpage and the section on "Gory details of parsing quoted constructs"
in the perlop manpage.

i Do case-insensitive pattern matching.

> However, when I try to
> use that as part of my regular expression (ex. (?i)^(CSV|ZIP|TXT)$)


This is not a regular expression. Well, it might be, but ...

> the result is a javascript error.


Your system must be badly screwed up. Why would perl report a javascript
error?

> The error says: "Syntax error in
> regular expression"
> (^(CSV|ZIP|TXT)$/i does not work)


At least the trailing /i is the correct syntax.
Please post a short, but selfcontained program that exposes the problem,
together with a description of what you expect the program to do versus what
behaviour you are observing. Then we may be able to determine if the problem
is with your code or your expectation.

> Any idea what I am doing wrong?


For once: not posting any actual code. How are we supposed to reproduce and
analyse your problem if you don't tell us how.

jue


 
Reply With Quote
 
Vijai Kalyan
Guest
Posts: n/a
 
      10-22-2004
(E-Mail Removed) (sabinosa) wrote in message news:<(E-Mail Removed). com>...
> Hi everyone,
> I am working with a RegularExpressionValidator in Visual Studio.NET.
> I would like to define a custom regular expression that ignores the
> letter case and therefore is case INsensitive. I have seen that the
> syntax might be something like "(?i)" or "/i". However, when I try to
> use that as part of my regular expression (ex. (?i)^(CSV|ZIP|TXT)$)
> the result is a javascript error. The error says: "Syntax error in
> regular expression"
> (^(CSV|ZIP|TXT)$/i does not work)
>
> Any idea what I am doing wrong? Thanks in advance for your responses!


(Javascript question in Javascript related newsgroup might get you more help.)

Simplest (and possibly the worst!) solution:

i. Convert your input into UPPERCASE. In c-talk:

int x=0;
static char s[INPUT_BUF_SIZE];
memset(s,'\x0',INPUT_BUF_SIZE);
strncpy(s,input,INPUT_BUF_SIZE];
for(; x != '\x0' && x < INPUT_BUF_SIZE ; toupper(s[x]), ++x);

ii. Check if 's' above matches.

iii. toupper is a macro, so this costs you time linear to size of your input.

BTW,

------------------------------
[>] RegExp Syntax

var myRegExp = /pattern/[switch]

In a Regular Expression /pattern/ is a Regular Expression and [switch]
(optional) indicates the mode in which the Regular Expression is to be used:

"i" - ignore case,
"g" - global search,
"gi" - global search + ignore case (case-insensitive).

After a Regular Expression is created, it is passed to a Method of a String
Object.
------------------------------

so why not try,

var input = /^(CSV|ZIP|TXT)$/[i]

?

The answer to your question (finally) is:

google case insensitive pattern matching in javascript





hth,
------
vijai.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
check file exists with case sensitive on a case insensitive filesystem Xah Lee Perl Misc 4 04-05-2009 11:21 PM
case insensitive find on case sensitive stl map benhoefer@gmail.com C++ 1 04-06-2007 08:42 PM
regular expression for case insensitive USA state codes Stan ASP .Net 1 05-16-2006 08:27 PM
case INsensitive regular expressions sabinosa Perl Misc 2 10-22-2004 09:10 PM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM



Advertisments