467,122 Members | 1,305 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,122 developers. It's quick & easy.

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
  • viewed: 971
Share:
3 Replies
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@gmail.com | 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@gmail.com | last post: by
reply views Thread by Karch | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.