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 | | | | re: Regex Vb.net question
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" <consult_Chris@nospam.yahoo.com> wrote in message
news:%23vgGm$$$FHA.3048@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 | | | | re: Regex Vb.net question
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:eFbNHLAAGHA.140@TK2MSFTNGP12.phx.gbl...[color=blue]
>
>
> 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" <consult_Chris@nospam.yahoo.com> wrote in message
> news:%23vgGm$$$FHA.3048@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
>[/color] | | | | re: Regex Vb.net question
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" <consult_Chris@nospam.yahoo.com> wrote in message
news:%23ElYoaAAGHA.3852@TK2MSFTNGP14.phx.gbl...[color=blue]
> 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:eFbNHLAAGHA.140@TK2MSFTNGP12.phx.gbl...[color=green]
>>
>>
>> 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" <consult_Chris@nospam.yahoo.com> wrote in message
>> news:%23vgGm$$$FHA.3048@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
>>[/color]
>
>[/color] | | | | re: Regex Vb.net question
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:eFbNHLAAGHA.140@TK2MSFTNGP12.phx.gbl...[color=blue]
>
>
> 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" <consult_Chris@nospam.yahoo.com> wrote in message
> news:%23vgGm$$$FHA.3048@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
>[/color] | | | | re: Regex Vb.net question
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" <consult_Chris@nospam.yahoo.com> wrote in message news:%23KdlxsBAGHA.3864@tk2msftngp13.phx.gbl...[color=blue]
> 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:eFbNHLAAGHA.140@TK2MSFTNGP12.phx.gbl...[color=green]
>>
>>
>> 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" <consult_Chris@nospam.yahoo.com> wrote in message
>> news:%23vgGm$$$FHA.3048@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
>> [/color]
>
>[/color] |  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,419 network members.
|