473,385 Members | 2,044 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,385 software developers and data experts.

Regex pattern match

I'm having trouble with a pattern match expression using
regex.

I need to have the first 4 characters as letters and the
next 2 characters as digits.
ex... PROJ12 - when trying "\D{4}\d{2}" as the
expression string.. it does not work on the .ismatch
function when i enter "proj12" into a text box.

What is the problem here?

Dim expressinvoice As New Regex("R-\d{3}\D{3,4}")
Dim expressvend As New Regex("^\D{4}\d{2}$")
Dim expressent As New Regex("\d{4}")

Dim svend As String
Dim sinv As String
Dim sent As String

sent = Trim(txtent.Text)
svend = Trim(txtvend.Text)
sinv = Trim(txtinvoice.Text)

If Not expressent.IsMatch(sent) Then
MsgBox("entity does not match format")

Exit Sub
End If
If expressvend.IsMatch(svend) Then

MsgBox("vendor is not a match")

Exit Sub
ElseIf expressinvoice.IsMatch(sinv) Then

MsgBox("invoice does not match format")
Exit Sub
End If
Nov 20 '05 #1
1 1429
Larry,
The following works:
Dim expressvend As New Regex("^\D{4}\d{2}$")
Dim svend As String
svend = "proj12"
If Not expressvend.IsMatch(svend) Then

MsgBox("vendor is not a match")

Exit Sub End If

Note you are missing the "Not" on the expressvend.IsMatch expression.

Hope this helps
Jay

"larry" <la***@larrymckay.com> wrote in message
news:08****************************@phx.gbl... I'm having trouble with a pattern match expression using
regex.

I need to have the first 4 characters as letters and the
next 2 characters as digits.
ex... PROJ12 - when trying "\D{4}\d{2}" as the
expression string.. it does not work on the .ismatch
function when i enter "proj12" into a text box.

What is the problem here?

Dim expressinvoice As New Regex("R-\d{3}\D{3,4}")
Dim expressvend As New Regex("^\D{4}\d{2}$")
Dim expressent As New Regex("\d{4}")

Dim svend As String
Dim sinv As String
Dim sent As String

sent = Trim(txtent.Text)
svend = Trim(txtvend.Text)
sinv = Trim(txtinvoice.Text)

If Not expressent.IsMatch(sent) Then
MsgBox("entity does not match format")

Exit Sub
End If
If expressvend.IsMatch(svend) Then

MsgBox("vendor is not a match")

Exit Sub
ElseIf expressinvoice.IsMatch(sinv) Then

MsgBox("invoice does not match format")
Exit Sub
End If

Nov 20 '05 #2

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

Similar topics

9
by: taylorjonl | last post by:
I am having a problem matching some text. It is a very simple pattern but it doesn't seem to work. Here goes. <td*>.*?</td> That is the pattern, it should match any <td></td> pair. Here is...
8
by: tomb | last post by:
I have found much documentation on specific patterns, but I can't find anything explaining how to reject strings that match both groups. My string could contain specific letters or numbers. If...
8
by: sherifffruitfly | last post by:
Hi, I've been searching as best I can for this - coming up with little. I have a file that is full of lines fitting this pattern: (?<year>\d{4}),(?<amount>\d{6,7}) I'm likely to get a...
1
by: Prabhu Gurumurthy | last post by:
Hello all - I have a file which has IP address and subnet number and I use regex to extract the IP separately from subnet. pattern used for IP: \d{1,3}(\.\d{1,3}){3} pattern used for...
7
by: jaylucier | last post by:
Howdy, I'm trying to break an input string into multpile pieces using a series of delimiters that start with an asterisk. Following the asterisk is a mulitple character identifier immediately...
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: 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: 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
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...
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.