473,473 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Regular Expression required

RegEx heros,

I want to validate a certain field such that it shouldn't contain the
percentage character (%) or the asterisk character symbol (*). The
specification is that:

(1) The field must not contain the percentage symbol; AND
(2) The field must not contain the asterisk symbol.

It should contain neither of them. Can you please help me with the
RegEx for this?

Nov 21 '05 #1
2 1438
Sathyaish,

Try something like:

Private Sub MyTextBox_KeyPress(ByVal sender As Object, _

ByVal e As System.Windows.Forms.KeyPressEventArgs) _

Handles MyTextBox.KeyPress

e.Handled = ChkEntry(e.KeyChar)

End Sub

Private Function ChkEntry(ByVal c As Char) As Boolean

Return c = "%" Or c = "%"

End Function

Doug
"Sathyaish" <sa*******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
RegEx heros,

I want to validate a certain field such that it shouldn't contain the
percentage character (%) or the asterisk character symbol (*). The
specification is that:

(1) The field must not contain the percentage symbol; AND
(2) The field must not contain the asterisk symbol.

It should contain neither of them. Can you please help me with the
RegEx for this?

Nov 21 '05 #2
Hi,

You can use the regex ismatch method to tell if the character is
the string.

Dim rMatch As New System.Text.RegularExpressions.Regex("[%*]")
Trace.WriteLine(rMatch.IsMatch("There is a 10% drop in sales"))
Trace.WriteLine(rMatch.IsMatch("10 * 12 equals 120"))
Trace.WriteLine(rMatch.IsMatch("There is a 10 percent drop in sales"))
Ken
---------------------------
"Sathyaish" <sa*******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
RegEx heros,

I want to validate a certain field such that it shouldn't contain the
percentage character (%) or the asterisk character symbol (*). The
specification is that:

(1) The field must not contain the percentage symbol; AND
(2) The field must not contain the asterisk symbol.

It should contain neither of them. Can you please help me with the
RegEx for this?

Nov 21 '05 #3

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

Similar topics

7
by: YoBro | last post by:
Hi I have used some of this code from the PHP manual, but I am bloody hopeless with regular expressions. Was hoping somebody could offer a hand. The output of this will put the name of a form...
9
by: Ron Adam | last post by:
Is it possible to match a string to regular expression pattern instead of the other way around? For example, instead of finding a match within a string, I want to find out, (pass or fail), if...
3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
3
by: Danny | last post by:
I am trying to do a regular expression to search for a url so anything that has http:\\www.hellothere.com but may not have the http:\\ and may not have the www and may not have http:\\www and...
2
by: Nazir | last post by:
Hi I'm using a regular expression validator, but if spaces are entered, it bypasses the validation! I'm using ^{5,100}$
2
by: Scott | last post by:
All I need is a Regular expression that checks to make sure the value is a number that is under 9 characters long (a number between 1 and 999999999). It is not a required field but if the user...
5
by: John . | last post by:
I am using the Regular Expression Validator control to validate a correct email address. But, at the same time I would like to make it a required field. I tested by using just the regular...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
18
by: Lit | last post by:
Hi, I am looking for a Regular expression for a password for my RegExp ValidationControl Requirements are, At least 8 characters long. At least one digit At least one upper case character
8
by: Uwe Schmitt | last post by:
Hi, Is anobody aware of this post: http://swtch.com/~rsc/regexp/regexp1.html ? Are there any plans to speed up Pythons regular expression module ? Or is the example in this artricle too...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
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...
0
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,...
1
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.