472,144 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,144 software developers and data experts.

new to regex

Hi group, can the following be done by using a regex, I want a textbox only
to contain numbers or . / + - ^ , but I've never used a regex before so I
don't know how to go about it. Could I for example check if the typed
character is in a given regex. Maybe this is a stupid question, I don't now.

grtz Peter
Nov 21 '05 #1
3 1058
I think if you look at the help it will tell you. I hardly ever use regex,
but the help clearly explains how to use it

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
Hi group, can the following be done by using a regex, I want a textbox
only
to contain numbers or . / + - ^ , but I've never used a regex before so I
don't know how to go about it. Could I for example check if the typed
character is in a given regex. Maybe this is a stupid question, I don't
now.

grtz Peter

Nov 21 '05 #2
I'll check it out, thnx, nice signature BTW :-)

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:O2**************@TK2MSFTNGP12.phx.gbl...
I think if you look at the help it will tell you. I hardly ever use regex,
but the help clearly explains how to use it

--
OHM ( Terry Burns ) * Use the following to email me *

Dim ch() As Char = "ufssz/cvsotAhsfbuTpmvujpotXjui/OFU".ToCharArray()
For i As Int32 = 0 To ch.Length - 1
ch(i) = Convert.ToChar(Convert.ToInt16(ch(i)) - 1)
Next
Process.Start("mailto:" & New String(ch))
--
"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
Hi group, can the following be done by using a regex, I want a textbox
only
to contain numbers or . / + - ^ , but I've never used a regex before so I don't know how to go about it. Could I for example check if the typed
character is in a given regex. Maybe this is a stupid question, I don't
now.

grtz Peter


Nov 21 '05 #3
Peter,
Do you want a well formed value in the textbox or just those characters?

Here is a sample RegEx used in the Validating event of the TextBox for jsut
those characters (not well formed).

Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
Const pattern As String = "^[\d./+-^,]+$"
Static theRegex As New System.Text.RegularExpressions.Regex(pattern,
System.Text.RegularExpressions.RegexOptions.Compil ed)
If theRegex.IsMatch(TextBox1.Text) Then
Me.ErrorProvider1.SetError(TextBox1, "")
Else
Me.ErrorProvider1.SetError(TextBox1, "Invalid characters")
e.Cancel = True
End If
End Sub

The following sites provide a wealth of information on regular expressions.

A tutorial & reference on using regular expressions:
http://www.regular-expressions.info/

The MSDN's documentation on regular expressions:
http://msdn.microsoft.com/library/de...geElements.asp
Hope this helps
Jay

"Peter Proost" <pp*****@nospam.hotmail.com> wrote in message
news:eb**************@TK2MSFTNGP12.phx.gbl...
Hi group, can the following be done by using a regex, I want a textbox
only
to contain numbers or . / + - ^ , but I've never used a regex before so I
don't know how to go about it. Could I for example check if the typed
character is in a given regex. Maybe this is a stupid question, I don't
now.

grtz Peter

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Tim Conner | last post: by
20 posts views Thread by jeevankodali | last post: by
17 posts views Thread by clintonG | last post: by
6 posts views Thread by Extremest | last post: by
7 posts views Thread by Extremest | last post: by
3 posts views Thread by aspineux | last post: by
15 posts views Thread by morleyc | last post: by
reply views Thread by Karch | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

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.