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.Tex t)
svend = Trim(txtvend.Te xt)
sinv = Trim(txtinvoice .Text)
If Not expressent.IsMa tch(sent) Then
MsgBox("entity does not match format")
Exit Sub
End If
If expressvend.IsM atch(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 1 1461
Larry,
The following works: Dim expressvend As New Regex("^\D{4}\d {2}$") Dim svend As String
svend = "proj12"
If Not expressvend.IsM atch(svend) Then
MsgBox("vendor is not a match")
Exit Sub
End If
Note you are missing the "Not" on the expressvend.IsM atch expression.
Hope this helps
Jay
"larry" <la***@larrymck ay.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.Tex t) svend = Trim(txtvend.Te xt) sinv = Trim(txtinvoice .Text)
If Not expressent.IsMa tch(sent) Then MsgBox("entity does not match format")
Exit Sub End If
If expressvend.IsM atch(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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 my
input data.
<td valign="top">Buyer<a href="http://www.google.com">google</a><img
src="www.google.com/s.gif" width="4" border="0">(<a
|
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 there are
numbers, then it should NOT have the letters. If it has the letters,
then it should NOT have the numbers.
My pattern for the letters is and numbers is the entire range
.
How can I specify matching one group or the other, and not both?
|
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 bunch of hits with this - I'm only interested in
the *last* one. Is there a way to build the concept "last" into the
|
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 subnet:((\d{1,3})|(\d{1,3}(\.\d{1,3}){1,3}))/(\d{1,2})
so I have list of ip/subnets strewn around like this
|
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 followed by a
data string of variable length. The input string may contain more than
one identifier anywhere in the string.
Here is an example:
*CZ1 2.3 4-56 *fuuuS24364 08 23 72
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
| |
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |