473,386 Members | 1,699 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,386 software developers and data experts.

Regex Vb.net question

How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String = "^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions = ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add New-->Class.

Then from inside another one of my project files I...

Dim MyVariable As New Regulator.RegularExpression

Now what do I have to do to use this expression?

Any help would be greatly appreciated.

Thanks,

Chris

Dec 13 '05 #1
5 5065


Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As
System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = reg.Matches("your text here", regex)
For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

[]s
Cesar

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add
New-->Class.
Then from inside another one of my project files I...
Dim MyVariable As New Regulator.RegularExpression
Now what do I have to do to use this expression?
Any help would be greatly appreciated.
Thanks,
Chris
Dec 13 '05 #2
Hi Cesar,

Thanks for the reply!

When I pasted the code into my project I got a get errors. After doing
whatever I had to do to make the errors go away I just wanted to make sure
that I didn't screw things up

Here is what I have now:

Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions = _
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace
Or _
System.Text.RegularExpressions.RegexOptions.Single line) _
Or System.Text.RegularExpressions.RegexOptions.Ignore Case)

Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = System.Text.RegularExpressions.Regex.Matches("your text
here", regex)

For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

Another question: is this code using the class from my original post? Is
that auto-generated class usful at all or should I not be concerned with it?

Thanks again,

Chris
"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:eF*************@TK2MSFTNGP12.phx.gbl...


Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions
= ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As
System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = reg.Matches("your text here", regex)
For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

[]s
Cesar

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost
if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add
New-->Class.
Then from inside another one of my project files I...
Dim MyVariable As New Regulator.RegularExpression
Now what do I have to do to use this expression?
Any help would be greatly appreciated.
Thanks,
Chris

Dec 13 '05 #3
The first line in my last post should read:

When I pasted the code into my project I got errors.

Sorry about the type-o

Chris

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Cesar,

Thanks for the reply!

When I pasted the code into my project I got a get errors. After doing
whatever I had to do to make the errors go away I just wanted to make sure
that I didn't screw things up

Here is what I have now:

Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions = _

((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or _
System.Text.RegularExpressions.RegexOptions.Single line) _
Or System.Text.RegularExpressions.RegexOptions.Ignore Case)

Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = System.Text.RegularExpressions.Regex.Matches("your
text here", regex)

For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

Another question: is this code using the class from my original post? Is
that auto-generated class usful at all or should I not be concerned with
it?

Thanks again,

Chris
"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:eF*************@TK2MSFTNGP12.phx.gbl...


Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions
= ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace
Or System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As
System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = reg.Matches("your text here", regex)
For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

[]s
Cesar

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost
if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add
New-->Class.
Then from inside another one of my project files I...
Dim MyVariable As New Regulator.RegularExpression
Now what do I have to do to use this expression?
Any help would be greatly appreciated.
Thanks,
Chris


Dec 13 '05 #4
The following line:
objMatches = reg.Matches("your text here", regex)

Gives me the following warning:
Access of shared member through an instance; qualifying expression will not
be evaluated

The VB 2005 IDE suggest to change reg.Matches() to Regex.matches

If I accept the change then the warning goes away.

My issue is then what happens to my RegexOptions that I set?

Chris
"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:eF*************@TK2MSFTNGP12.phx.gbl...


Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions
= ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As
System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = reg.Matches("your text here", regex)
For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

[]s
Cesar

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost
if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add
New-->Class.
Then from inside another one of my project files I...
Dim MyVariable As New Regulator.RegularExpression
Now what do I have to do to use this expression?
Any help would be greatly appreciated.
Thanks,
Chris

Dec 13 '05 #5
Sorry for the delay, I was away for a while. I tested the code below and works, try again:
Dim options As System.Text.RegularExpressions.RegexOptions = ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim regex As String = "^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim reg As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(regex, options)
Dim objMatches As System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match

objMatches = reg.Matches("your text here", regex)

For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

About your other question, yes I just copy and paste your original code and implemented the use of Matches collection. Personally, the only thing I don't like The Regulator auto code is variables nomenclatures. The rest is Ok.

[]s
Cesar


"Chris" <co***********@nospam.yahoo.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
The following line:
objMatches = reg.Matches("your text here", regex)

Gives me the following warning:
Access of shared member through an instance; qualifying expression will not
be evaluated

The VB 2005 IDE suggest to change reg.Matches() to Regex.matches

If I accept the change then the warning goes away.

My issue is then what happens to my RegexOptions that I set?

Chris


"Cesar Ronchese" <ronchese_hotmail_dot_com> wrote in message
news:eF*************@TK2MSFTNGP12.phx.gbl...


Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions
= ((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)

Dim objMatches As
System.Text.RegularExpressions.MatchCollection
Dim objMatch As System.Text.RegularExpressions.Match
objMatches = reg.Matches("your text here", regex)
For Each objMatch In objMatches
Debug.WriteLine(objMatch.Value)
objMatch = Nothing
Next

[]s
Cesar

"Chris" <co***********@nospam.yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
How Do I use the following auto-generated code from The Regulator?

'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.1.4322.2032
'
' Changes to this file may cause incorrect behavior and will be lost
if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------

Option Strict Off
Option Explicit On
Namespace Regulator

Public Class RegularExpression

Private Sub Test()
Dim regex As String =
"^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))+\.(txt|TXT)$"
Dim options As System.Text.RegularExpressions.RegexOptions =
((System.Text.RegularExpressions.RegexOptions.Igno rePatternWhitespace Or
System.Text.RegularExpressions.RegexOptions.Multil ine) _
Or
System.Text.RegularExpressions.RegexOptions.Ignore Case)
Dim reg As System.Text.RegularExpressions.Regex = New
System.Text.RegularExpressions.Regex(regex, options)
End Sub
End Class
End Namespace

I've placed this code in it's own file by clicking on Project-->Add
New-->Class.
Then from inside another one of my project files I...
Dim MyVariable As New Regulator.RegularExpression
Now what do I have to do to use this expression?
Any help would be greatly appreciated.
Thanks,
Chris


Dec 13 '05 #6

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

Similar topics

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...
8
by: vbmark | last post by:
I'm new to RegEx in vb.net so I'm not sure how to do this. I want to know if a string contains two minus signs "-". If there are two then I want it to return TRUE. I also need to know if the...
1
by: JM | last post by:
Hi, I am not sure if this is the place to post a REGEX question if not, please indicate me where i can post it?. My question: Given a string like: "Boston. MA. Holidays" I need to define the...
6
by: Sa¹o Zagoranski | last post by:
Hi, could someone help me putting together a regex expression for my problem? I need my search filter to treat spaces and commas in the query the same way no matter how many there are... ...
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...
2
by: GS | last post by:
How can one avoid capturing leading empty or blank lines? the data I deal with look like this "will be paid on the dates you specified. xyz supplier amount: $100.52 when: September 07,...
4
by: pedrito | last post by:
I have a regex question and it never occurred to me to ask here, until I saw Jesse Houwing's quick response to Phil for his Regex question. I have some filenames that I'm trying to parse out of...
3
by: Peter Proost | last post by:
Hi group first of all I need to say that I almost never use regex hence my question may be stupid. I'm using regex to find all words that start with an @ in a string. But the regex that I figured...
0
by: Tim N. van der Leeuw | last post by:
Hey Gerhard, Gerhard Häring wrote: I so far forgot to say a "thank you" for the suggestion :-) The sample code as you sent it doesn't do what I need to do, but I did look at it for...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
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.