473,769 Members | 6,799 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating Royal Mail shipping with vb.net and regular expressions

I needed to use a regular expression to validate the shipping code that
was/is scanned by my application.

I use a windows (winform) application in Vb.net. I did it by creating
a function to handle the validation, and return true or false depending
on the value it received (which is just input from a scanner).
Make sure to import system.text.reg ularexpressions

Private Function ValidWaybill(By Ref strWaybill As String) As Boolean

If Regex.IsMatch(s trWaybill, "^([A-Z]{2})([
]{1})([0-9]{4})([ ]{1})([0-9]{4})([ ]{1})([0-9]{1})([A-Z]{2})$") = True
Then
ValidWaybill = True
Else
ValidWaybill = False
End If

End Function

This works for me, at least it seems to.
The format of the value I need to validate is like this:

"AA 0000 0000 0AA"

So I made an expression that looks for two capital letters, followed by
a space. Next is two sets of 4 digit numbers, followed by spaces.
Last is one number, followed by two capital letters.

In my production code, the expression is stored in an XML file, and
this function reads it when it runs. This way, if I made a mistake, I
can fix it without re-compiling.

Hope this is usefull for someone!

Ciao.

Idletask

Nov 21 '05 #1
2 1848
Hi,

RegexLib.com has plenty of examples of regular expressions. I
believe this the pattern you are looking for.

http://www.regexlib.com/REDetails.aspx?regexp_id=583

Ken
------------------
<id******@msn.c om> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
I needed to use a regular expression to validate the shipping code that
was/is scanned by my application.

I use a windows (winform) application in Vb.net. I did it by creating
a function to handle the validation, and return true or false depending
on the value it received (which is just input from a scanner).
Make sure to import system.text.reg ularexpressions

Private Function ValidWaybill(By Ref strWaybill As String) As Boolean

If Regex.IsMatch(s trWaybill, "^([A-Z]{2})([
]{1})([0-9]{4})([ ]{1})([0-9]{4})([ ]{1})([0-9]{1})([A-Z]{2})$") = True
Then
ValidWaybill = True
Else
ValidWaybill = False
End If

End Function

This works for me, at least it seems to.
The format of the value I need to validate is like this:

"AA 0000 0000 0AA"

So I made an expression that looks for two capital letters, followed by
a space. Next is two sets of 4 digit numbers, followed by spaces.
Last is one number, followed by two capital letters.

In my production code, the expression is stored in an XML file, and
this function reads it when it runs. This way, if I made a mistake, I
can fix it without re-compiling.

Hope this is usefull for someone!

Ciao.

Idletask
Nov 21 '05 #2
Hi-
thanks for that link. I didn't know about that website. I think I
have the pattern I need though. I am not an expert with regular
expressions, but that pattern looks a little different than what I
need. I will compare this to what I came up and and see what works
better.

Thanks again!

Nov 21 '05 #3

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

Similar topics

8
13542
by: UndoMiel | last post by:
Hi, I am looking for a way to validate IP addresses using XML Schemas. The following is what i used: <xsd:simpleType name="IPType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="((? | 1 | 2 | 25)\.){3} (? | 1 |
7
2679
by: monomaniac21 | last post by:
Hi guys! Can anyone tell me how you can perform validation on a string variable in PHP so that you can check if a specific character is contained within the string. The reason for this is i am trying to create a form for a site i am making and i want to validate the user's input for the email address field, by ensuring it contains the '@' character. Cheers.
2
1674
by: charleswesley | last post by:
I find myself regularly needing to validate user input as either a) numeric only or b) valid email address format (user@domain.tld) I am assuming that there are regular expressions that can be used to do this as it doesn't appear that 1.1 includes this functionality itself. I am interested to know if anyone has a simple vb.net example of a solution to either of these issues. I'm new to regular expressions but if I have a working...
1
5271
by: cemcat | last post by:
Hello, We have an ASP.NET 2.0 (C#) web form that contains a textbox for users to enter multiple e-mail addresses separated by semicolons. We need to validate that each individual e-mail address entered is a valid e-mail address format. We've added a CustomValidator to perform this validation. We have the server-side validation working fine, but now we need to add some client-side validation via JavaScript. We are having difficulties...
4
2767
by: SAL | last post by:
I am using a RegularExpressionValidator control on my ASP page, and I have the ValidationExpression property set to "Internet E-mail Address". The email address is valiated when the user puts in a email addess in the TextBox. This works fine until I have multiple email addresses. How can I validate multiple e-mail addresses seperated by a "," or ";"? The following ValidationExpression will validate up to 2 email addresses but not...
1
10066
by: bobano | last post by:
Hi everyone, I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol. This program can perform 5 options from a menu on your POP3 mail by logging in with the correct POP3 server along with a user name and password that you use to log in to your ISP. The user name and password as well as the server name are all hard-coded...
5
4817
by: ameen.abdullah | last post by:
Hi Guys, I have a textbox in windows form that should only accept alphabets, numbers, spaces and underscore. If the textbox contains anyother character it should display a msg at the time of validation.. Is there any funciton in vb.net for this? or any other way?? Waiting for ur replies...
232
13343
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
10
1671
by: venugopal.sjce | last post by:
Hi Friends, I'm constructing a regular expression for validating an expression which looks as any of the following forms: 1. =4*++2 OR 2. =Sum()*6 Some of the samples I have constructed below:
0
9590
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9424
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,...
0
10051
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 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...
0
8879
agi2029
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...
1
7413
isladogs
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...
0
6675
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();...
0
5310
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...
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.