473,385 Members | 1,958 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.

Regular expression in VB6

Hello,

I am wanting to use regEx (regular expression) in visual basic code (vb6.0)

I have one field on a form that will get inputs from a user in the following format, (note the 3 numbers of the end will change)
HNPSD/001
HNPSD/002
HNPSD/004
HNPSD/999
etc

I need the pattern/rules/constriants for this text format, so how to ensure that the HNPSD/ is always entered and that the next three digits are between 0-9.

something along the lines of: (or i might be way off)
eg_exp.Pattern = "^[0-9]*3"

Thanks

Jac
Dec 24 '12 #1
3 2420
zmbd
5,501 Expert Mod 4TB
I believe that you meant to post to VB/.net as that is the specific reference in the question.

However on the off chance that you did intend the VBA forum:

MS Access VBA does not normally support RegEX; however, I do believe that in the library references one can add a reference to the Microsoft VBScript Regular Expressions library. Microsoft Beefs Up VBScript with Regular Expressions

I believe that is is library reference: "Microsoft VBScript Regular Expressions 1.0" and then in v2010 there is also "Microsoft VBScript Regular Expressions 5.5"

>HOWEVER< I have not personally tried this; thus, if you do and things work out please post back to this thread!
Dec 24 '12 #2
Rabbit
12,516 Expert Mod 8TB
As far as your expression goes:

1) You don't have "HNPSD/" anywhere in your expression.
2) The * character is used to match the specified character 0 to infinite times.
3) Your 3 in the expression needs to be surrounded by curly brackets, otherwise it will look for the character 3.
4) You have the start anchor but you're missing the ending anchor.
Dec 24 '12 #3
NeoPa
32,556 Expert Mod 16PB
ANSI Standards in String Comparisons will give the background for this question, but the simple answer is :
Expand|Select|Wrap|Line Numbers
  1. [X] Like 'HNPSD/###'
Dec 24 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

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...
4
by: Neri | last post by:
Some document processing program I write has to deal with documents that have headers and footers that are unnecessary for the main processing part. Therefore, I'm using a regular expression to go...
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,...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In...
7
by: Billa | last post by:
Hi, I am replaceing a big string using different regular expressions (see some example at the end of the message). The problem is whenever I apply a "replace" it makes a new copy of string and I...
9
by: Pete Davis | last post by:
I'm using regular expressions to extract some data and some links from some web pages. I download the page and then I want to get a list of certain links. For building regular expressions, I use...
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...
0
by: altavim | last post by:
Usually when you make regular expression to extract text you are starting from simple expression. When you got to know target text, you are extending your expression. Subsequently very hard to ready...
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
14
by: Andy B | last post by:
I need to create a regular expression that will match a 5 digit number, a space and then anything up to but not including the next closing html tag. Here is an example: <startTag>55555 any...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.