473,383 Members | 1,735 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,383 software developers and data experts.

Regular Expression

263 100+
Hi there.

I have necessity of Regular Expression what it checks this syntax:

Expand|Select|Wrap|Line Numbers
  1. AAA BBB 12C21 D345 E
I write:

Expand|Select|Wrap|Line Numbers
  1. var cfReg = new RegExp("[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]")
It's not working, can anyone help?

Kind regards
viki1967
Nov 18 '07 #1
8 1022
gits
5,390 Expert Mod 4TB
hi ...

should it be exactly that syntax? only upper cases and the spaces too?

kind regards
Nov 18 '07 #2
viki1967
263 100+
Hi...

Yes exactly please:

Expand|Select|Wrap|Line Numbers
  1. AAA BBB 12C21 D345 E
Kind regards.
Nov 19 '07 #3
andho
34
the regex you have given will not match if there are spaces in the string. so that might the problem!!
Nov 19 '07 #4
gits
5,390 Expert Mod 4TB
hi ...

at a first quick shot you may use:

Expand|Select|Wrap|Line Numbers
  1. var re = /[A-Z]{3}[ ]{1}[A-Z]{3}[ ]{1}[A-Z1-9]{5}[ ]{1}[A-Z1-9]{4}[ ]{1}[A-Z]{1}/;
  2.  
  3. var val = re.test('AAA BBB 12X21 D345 E');
  4.  
  5. // now val is true ... :)
  6.  
kind regards
Nov 19 '07 #5
viki1967
263 100+
hi.

Thanks; but It's not working everytime :

Expand|Select|Wrap|Line Numbers
  1. AAA BBB 12X21 D345 E
It's OK

Expand|Select|Wrap|Line Numbers
  1. GPL VBN 69E09 H273 J
It's KO...

Why?
Nov 19 '07 #6
gits
5,390 Expert Mod 4TB
of course ... :) sorry ... you have to replace 1-9 with 0-9 ...

Expand|Select|Wrap|Line Numbers
  1. var re = /[A-Z]{3}[ ]{1}[A-Z]{3}[ ]{1}[A-Z0-9]{5}[ ]{1}[A-Z0-9]{4}[ ]{1}[A-Z]{1}/
kind regards
Nov 19 '07 #7
viki1967
263 100+
Your sincerely.

Viki1967
Nov 20 '07 #8
gits
5,390 Expert Mod 4TB
hi ... :)

glad it works now ... post back to the forum anytime you have more questions ...

kind regards
Nov 20 '07 #9

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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...

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.