473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

basic regex question



....hoping someone can help someone still new to vb.net 2005 with something
new to him.

....been successfully using the regular expression validators from the
toolbox, but now I have need to do something strictly with code.

....need to determine if a stored string matches a stored regular expression.

....not sure what to search under for an example to give me a starting point.
I can figure out the actual expression syntax and the rest if someone can
get me started.

e.g., something along these lines

dim myregex as new regex
if mystoredstring = regex then
DoAllKindsOfStuff()
end if

Thanks

jeff
--
Posted via a free Usenet account from http://www.teranews.com

May 17 '07 #1
5 1245
Jeff wrote:
...hoping someone can help someone still new to vb.net 2005 with
something new to him.

...been successfully using the regular expression validators from the
toolbox, but now I have need to do something strictly with code.

...need to determine if a stored string matches a stored regular
expression.
I think you're looking for the RegEx.IsMatch method.

Andrew
May 17 '07 #2
On May 17, 12:52 am, "Jeff" <n...@nothingX.comwrote:
...hoping someone can help someone still new to vb.net 2005 with something
new to him.

...been successfully using the regular expression validators from the
toolbox, but now I have need to do something strictly with code.

...need to determine if a stored string matches a stored regular expression.

...not sure what to search under for an example to give me a starting point.
I can figure out the actual expression syntax and the rest if someone can
get me started.

e.g., something along these lines

dim myregex as new regex
if mystoredstring = regex then
DoAllKindsOfStuff()
end if

Thanks

jeff

--
Posted via a free Usenet account fromhttp://www.teranews.com
Off the top of my head:

Imports System.Text.RegularExpressions

If Regex.IsMatch(mystoredstring, myregexpattern) Then
DoAllKindsOfStuff()
end if

Thanks,

Seth Rowe

May 17 '07 #3

"Jeff" <no**@nothingX.comwrote in message
news:46***********************@free.teranews.com.. .
>

Okay, now I'm really confused.

I got this figured out somewhat, but either there is a major bug somewhere,
or I don't understand something fundamental (and it is likely the latter)

If I uses a regular expression validator from the toolbox and the expression
[a-zA-Z1-9]* it will properly match letters and numbers.

The exact same regular expression in the code below fails and matches
everything. Something seems to be going on everytime that I enter a reg
expression with a bracket - it will work with the toolbox validator, but not
when I use all vb code.

Can someone explain? I'm lost.

Dim regexobj As Regex = New Regex("[a-zA-Z1-9]*")

If RegexObj.IsMatch(TBUser.Text) = False Then

--
Posted via a free Usenet account from http://www.teranews.com

May 18 '07 #4
On May 18, 6:33 pm, "Jeff" <no_...@george.comwrote:
"Jeff" <n...@nothingX.comwrote in message

news:46***********************@free.teranews.com.. .

Okay, now I'm really confused.

I got this figured out somewhat, but either there is a major bug somewhere,
or I don't understand something fundamental (and it is likely the latter)

If I uses a regular expression validator from the toolbox and the expression
[a-zA-Z1-9]* it will properly match letters and numbers.

The exact same regular expression in the code below fails and matches
everything. Something seems to be going on everytime that I enter a reg
expression with a bracket - it will work with the toolbox validator, but not
when I use all vb code.

Can someone explain? I'm lost.

Dim regexobj As Regex = New Regex("[a-zA-Z1-9]*")

If RegexObj.IsMatch(TBUser.Text) = False Then

--
Posted via a free Usenet account fromhttp://www.teranews.com
I'm just guessing - but it may have to do with the RegexOptions you
are using - try experimenting with them and see if it makes a
difference.

Also, you might want to post some sample text and the complete regex
pattern that is causing the problem - that way I can take a better
look at it.

Thanks,

Seth Rowe

May 19 '07 #5

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
I'm just guessing - but it may have to do with the RegexOptions you
are using - try experimenting with them and see if it makes a
difference.

Also, you might want to post some sample text and the complete regex
pattern that is causing the problem - that way I can take a better
look at it.

Thanks,

Seth Rowe

Okay, I think that I have much of this figured out. The validator through
the toolbox (is there a good way to say this?) does not evaluate empty
textbox values regardless of the regex expression, while the hardcoded
version works essentially like all of the instructions that I see about
using regex. I didn't pick up on that initially, and that was causing the
confusion.

I think that I have it going now.

Thanks for the help.

--
Posted via a free Usenet account from http://www.teranews.com

May 19 '07 #6

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

Similar topics

1
by: m|sf|t | last post by:
All, If I have this: $xmlstr = str_replace("&", "%amp;%", $xmlstr); How can I use use a regex expression (if it is needed) to do the replace UNLESS the string contains A&E (you know, the TV...
9
by: William Ryan | last post by:
How do I ignore something that's part of what I want to find. For instance..I have this string I have a regex \]\d*\] to find the whole thing. However, I don't want to have either of the...
4
by: engwar1 | last post by:
Not sure where to ask this. Please suggest another newsgroup if this isn't the best place for this question. I'm new to both vb.net and regex. I need a regular expression that will validate what...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
6
by: Du Dang | last post by:
Text: ===================== <script1> ***stuff A </script1> ***more stuff <script2> ***stuff B
5
by: Chris | last post by:
How Do I use the following auto-generated code from The Regulator? '------------------------------------------------------------------------------ ' <autogenerated> ' This code was generated...
6
by: Martin Evans | last post by:
Sorry, yet another REGEX question. I've been struggling with trying to get a regular expression to do the following example in Python: Search and replace all instances of "sleeping" with "dead"....
7
by: Extremest | last post by:
I am using this regex. static Regex paranthesis = new Regex("(\\d*/\\d*)", RegexOptions.IgnoreCase); it should find everything between parenthesis that have some numbers onyl then a forward...
5
by: =?Utf-8?B?VG9ueSBXaXNzbGVy?= | last post by:
Hello everyone- I am hoping a couple of you will have some ideas on this one... I have a webform created in visual basic 2005. Basically, the webform gather answers to the questions asked on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...

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.