473,387 Members | 1,572 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.

Why doesn't this regular expression work?


I'm having a problem and it's driving me crazy. This code does
not work when run under VB.NET, but it works in 2 regular expression
evaluators. Am I missing something here?

Chris

-----------

Sub test()
Dim testString As String = "Me.Button1.Name = 'Button1'"
Dim regVars As New Regex( _
"(?:^\s*)(?<name>.*)\s*=\s*(?<value>.*)(?=\r\n )", _
RegexOptions.IgnoreCase _
Or RegexOptions.Multiline _
Or RegexOptions.Compiled _
)
Dim regMC As MatchCollection = regVars.Matches(testString)
If regMC.Count > 0 Then
MsgBox("Success")
End If
End Sub
Nov 20 '05 #1
2 2054
Chris,

I think your problem is that you are searching for the line termination
characters and don't have them in your test string, but do have them in the
text box you are using to test the expression (using Expresso?). Try
changing the second line of your code to:

Dim testString As String = "Me.Button1.Name = 'Button1'" & vbCrLf

Jim
"Chris W." <Gu*******@No.Spam.Yahoo.Com> wrote in message
news:gt********************************@4ax.com...

I'm having a problem and it's driving me crazy. This code does
not work when run under VB.NET, but it works in 2 regular expression
evaluators. Am I missing something here?

Chris

-----------

Sub test()
Dim testString As String = "Me.Button1.Name = 'Button1'"
Dim regVars As New Regex( _
"(?:^\s*)(?<name>.*)\s*=\s*(?<value>.*)(?=\r\n )", _
RegexOptions.IgnoreCase _
Or RegexOptions.Multiline _
Or RegexOptions.Compiled _
)
Dim regMC As MatchCollection = regVars.Matches(testString)
If regMC.Count > 0 Then
MsgBox("Success")
End If
End Sub

Nov 20 '05 #2
On Sat, 30 Aug 2003 14:13:25 GMT, "Jim Hollenhorst"
<No****@altavista.com> wrote:
Chris,

I think your problem is that you are searching for the line termination
characters and don't have them in your test string, but do have them in the
text box you are using to test the expression (using Expresso?). Try
changing the second line of your code to:

Dim testString As String = "Me.Button1.Name = 'Button1'" & vbCrLf

Jim


That was it Jim, thanks! :-)) I figured it had to be something fairly
simple!

Chris
Nov 20 '05 #3

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

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
4
by: Buddy | last post by:
Can someone please show me how to create a regular expression to do the following My text is set to MyColumn{1, 100} Test I want a regular expression that sets the text to the following...
11
by: Dimitris Georgakopuolos | last post by:
Hello, I have a text file that I load up to a string. The text includes certain expression like {firstName} or {userName} that I want to match and then replace with a new expression. However,...
6
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address...
5
by: Ryan | last post by:
HELLO I am using the following MICROSOFT SUGGESTED (somewhere on msdn) regular expression to validate email addresses however I understand that the RFP allows for "+" symbols in the email address...
3
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is...
6
by: Ludwig | last post by:
Hi, i'm using the regular expression \b\w to find the beginning of a word, in my C# application. If the word is 'public', for example, it works. However, if the word is '<public', it does not...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
6
by: runsun pan | last post by:
Hi I am wondering why I couldn't get what I want in the following 3 cases of re: (A) var p=/(+-?+):(+)/g p.exec("style='font-size:12'") -- // expected
13
by: chadsspameateremail | last post by:
I might have found a problem with how preg_match works though I'm not sure. Lets say you have a regular expression that you want to match a string of numbers. You might write the code like this:...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.