473,608 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Regex query

When using the regular expression validator is there a way of failing a
validation when you detect a match - I suppose a sort of anti-match.

I want to detect certain things on user input and if they exist then fail
client-side validation.

An example would be detecting html input, a simple test of which would be to
look for '<[a-zA-z]',
but I would like to fail if this sequence is detected anywhere in a
multiline string.

Is there a way or is it down to server-side validation only?

Shaun

PS. I am still validating the input on the server-side I just wanted to cut
down on round trips
Nov 18 '05 #1
9 2796
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressi onValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework.
Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer
to:
http://msdn.microsoft.com/library/de...us/dnaspp/html
/aspplusvalid.as p

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconscriptfile forsample.asp

In the article, RegularExpressi onValidatorEval uateIsValid method contains
the original RegularExpressi onValidator control's logic. FYI.

=============== =============== ======
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #2
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressi onValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework.
Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer
to:
http://msdn.microsoft.com/library/de...us/dnaspp/html
/aspplusvalid.as p

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconscriptfile forsample.asp

In the article, RegularExpressi onValidatorEval uateIsValid method contains
the original RegularExpressi onValidator control's logic. FYI.

=============== =============== ======
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #3
Hi Jeffrey

yup I was thinking along those lines myself as an alternative action - so
what you suggest is that I do a custom validator and then invert the result.
Seems reasonable, I was just hoping there wassome unknown regex expression I
didn't know about.

I'll test it out later and get back to you

shaun

""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:Jx******** ******@cpmsftng xa06.phx.gbl...
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressi onValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework. Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer to:
http://msdn.microsoft.com/library/de...us/dnaspp/html /aspplusvalid.as p

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconscriptfile forsample.asp

In the article, RegularExpressi onValidatorEval uateIsValid method contains
the original RegularExpressi onValidator control's logic. FYI.

=============== =============== ======
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #4
Hi Jeffrey

yup I was thinking along those lines myself as an alternative action - so
what you suggest is that I do a custom validator and then invert the result.
Seems reasonable, I was just hoping there wassome unknown regex expression I
didn't know about.

I'll test it out later and get back to you

shaun

""Jeffrey Tan[MSFT]"" <v-*****@online.mi crosoft.com> wrote in message
news:Jx******** ******@cpmsftng xa06.phx.gbl...
Hi Shaun,

Based on my understanding, you want to reverse the process logic of
RegularExpressi onValidator control.

To get this done, I think you should use CustomValidator control, which
allows you to write your own code to take part in the validation framework. Then you can provide your own validate logic on the Form.

For more information about how to use CustomValidator control, please refer to:
http://msdn.microsoft.com/library/de...us/dnaspp/html /aspplusvalid.as p

At client side, you may use JScript's RegExp class to do the regular
expression operation. For more information, please refer to the client
Jscript souce code below:
http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconscriptfile forsample.asp

In the article, RegularExpressi onValidatorEval uateIsValid method contains
the original RegularExpressi onValidator control's logic. FYI.

=============== =============== ======
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #5
Hi Shaun,

Thanks for your feedback.

Yes, the key point is how to do the do the validation through regular
expression at client.

I will wait for your feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #6
Hi Shaun,

Thanks for your feedback.

Yes, the key point is how to do the do the validation through regular
expression at client.

I will wait for your feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #7
Hi Shaun,

Here's an alternative solution. My product "Profession al Validation And
More" (at http://www.peterblum.com/vam/home.aspx) is a replacement to the
built in validators that overcomes their numerous limitations. For example,
all of my 22 validators have a property called NotCondition that when true,
reverses the logic. So you'd plug in my RegexValidator, set the expression
that you want to be false and set NotCondition to true.
This works fully on the client side and my validators support more browsers
for client-side validation than Microsofts. (They support DHTML only; I
support IE, IE/Mac, Netscape/Mozilla, Opera 7, and Safari.)

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Shaun Wilde" <sh*********@no spam.co.uk> wrote in message
news:OH******** *****@TK2MSFTNG P09.phx.gbl...
When using the regular expression validator is there a way of failing a
validation when you detect a match - I suppose a sort of anti-match.

I want to detect certain things on user input and if they exist then fail
client-side validation.

An example would be detecting html input, a simple test of which would be to look for '<[a-zA-z]',
but I would like to fail if this sequence is detected anywhere in a
multiline string.

Is there a way or is it down to server-side validation only?

Shaun

PS. I am still validating the input on the server-side I just wanted to cut down on round trips

Nov 18 '05 #8
Hi Shaun,

Here's an alternative solution. My product "Profession al Validation And
More" (at http://www.peterblum.com/vam/home.aspx) is a replacement to the
built in validators that overcomes their numerous limitations. For example,
all of my 22 validators have a property called NotCondition that when true,
reverses the logic. So you'd plug in my RegexValidator, set the expression
that you want to be false and set NotCondition to true.
This works fully on the client side and my validators support more browsers
for client-side validation than Microsofts. (They support DHTML only; I
support IE, IE/Mac, Netscape/Mozilla, Opera 7, and Safari.)

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Shaun Wilde" <sh*********@no spam.co.uk> wrote in message
news:OH******** *****@TK2MSFTNG P09.phx.gbl...
When using the regular expression validator is there a way of failing a
validation when you detect a match - I suppose a sort of anti-match.

I want to detect certain things on user input and if they exist then fail
client-side validation.

An example would be detecting html input, a simple test of which would be to look for '<[a-zA-z]',
but I would like to fail if this sequence is detected anywhere in a
multiline string.

Is there a way or is it down to server-side validation only?

Shaun

PS. I am still validating the input on the server-side I just wanted to cut down on round trips

Nov 18 '05 #9
Hi Shaun,

Have you tried it yet? Do you still have any concern?

Please feel free to let me know, I will help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 18 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1879
by: Fazer | last post by:
Hello, I have a string which has a url (Begins with a http://) somewhere in it. I want to detect such a url and just spit out the url. Since I am very poor in regex, can someone show me how to do it using a few examples? Thanks a lot!
3
3012
by: a | last post by:
I'm a newbie needing to use some Regular Expressions in PHP. Can I safely use the results of my tests using 'The Regex Coach' (http://www.weitz.de/regex-coach/index.html) Are the Regular Expressions used in Perl identical to the Regular Expressions in PHP?
3
8490
by: jwgoerlich | last post by:
Hello group, I am working on a query string class. The purpose is to parse name-value pairs from incoming text. Currently, I am using the Regex code below. I have two questions. First, the code below does not work if there is a space in the name. For example, the text "Initial Catalog=test;" parses to name=Catalog and value=test.
0
1337
by: =?ISO-8859-15?Q?C=E9dric?= | last post by:
Hi all, I want to import a SQL script (SQLite) executing each queries separately. - I read the SQL file - I split the read string with the separator ";" - I execute each query string query = File.ReadAllText("C:\\script.sql"); string str = query.Split(';');
15
5986
by: nagar | last post by:
I need to split a string whenever a separator string is present (lets sey #Key(val) where val is a variable) and rejoin it in the proper order after doing some processing. Is there a way to use the Regex.Split function to split the string whenever the #Key(val) occurrs but that keeps the #Key(val) occurrences to that I can reconstruct the final string after doing certain operations on each token (I need to basically convert each string...
0
1183
by: rmccullough | last post by:
The test tool I use produces xml files that I am parsing and inserting into a mysql database. I then have a set of php pages that report on the test results. I wrote a C# console application that parses the xml file and performs the db insert. I am using MySQLDriverCS as the interface to mysql. The problem I am having is that it is a little slow. One of the bottlenecks I have is looking for the version string in the xml file. I created a...
0
1828
by: Guoqi Zheng | last post by:
Dear Sir, I need to use regex to replace some string. Below is what I use. output = "sample data <href=""xlink:GG44-33"">, part two <href=""xlink:GG55-123"">" Dim regEx Set regEx = New RegExp regEx.Pattern = "href=\""(xlink:.*?)\""" output = regEx.Replace(output,"href="&chr(34) &
0
1534
by: vmysore | last post by:
I am trying to get all the columns selected within a SQL query (including the sub selects). When the code hits matcher.find(). i get the following exception: Exception in thread "main" java.lang.StackOverflowError at java.util.regex.Pattern$Branch.match(Pattern.java:4530) at java.util.regex.Pattern$GroupHead.match(Pattern.java:4570) I am not sure where in the regex is causing the inifinite loop. Can anyone shed light on this?
4
1383
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
Prior to now, my RegEx expression was as follows: RegEx pattern = new Regex(@"\d{5} \d{4} \d{2}"); That has worked, but now I have been asked to enable the ability for our expressions to include an underscore ('_') at each of the character positions. (This is an SQL Query, and the underscore acts as a wildcard for individual characters) Is there a nice way to modify my RegEx expression to include the underscore
2
10642
by: Smokey Grindel | last post by:
I basically need to remove any leading zeros and hyphens from a string... regex seemed like the best rout and using a replace regex method... anyone know of any good strings for this? The one I just made quick is ^0+| but not having much experience with regex, is this the correct one?
0
8059
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6815
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.