473,779 Members | 2,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need regular expression for comma delimited list

I cannot get anything to validate a comma delimited list of stock
symbols, like "IBM, MSFT,INTC). symbols are alphanumeric with a maxium
length of 5. I want to block multiple, adjacent commas, and allow up
to two blank spaces between symbols.
The following did not work:
(\w{1,5}(, *)?)*

May 30 '07 #1
6 12976
>(\w{1,5}(, *)?)*

Maybe (\w{1,5}(,)?(\s +)?)* ?
You need a regular expression validator. I used to know one, but...
May 30 '07 #2
no************* @gmail.com wrote:
>(\w{1,5}(, *)?)*

Maybe (\w{1,5}(,)?(\s +)?)* ?
You need a regular expression validator. I used to know one, but...
Regex Coach?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
May 30 '07 #3
bi*********@yah oo.com wrote:
I cannot get anything to validate a comma delimited list of stock
symbols, like "IBM, MSFT,INTC). symbols are alphanumeric with a maxium
length of 5. I want to block multiple, adjacent commas, and allow up
to two blank spaces between symbols.
The following did not work:
(\w{1,5}(, *)?)*
It generally helps if you post what you actually tried and say exactly how
it failed to work. For example if you did:

/(\w{1,5}(, *)?)*/.test(somestrin g)

that will always evaluate to true because your expression matches an empty
string: you need to anchor it to the beginning and end of the string to do
any useful validation (and probably also you should insist on at least one
symbol). So something like this may be what you want:

/^\w{1,5}(?:,\s* \w{1,5})*$/.test(somestrin g)

On the other hand, if your problem was that:

/(\w{1,5}(, *)?)*/.exec('IBM, MSFT,INTC')

only saves the last of the symbols in a group then that would be a
misunderstandin g of how groups work.
May 30 '07 #4
Hi.
I hope this function will help you.
/**
* @author
* Georgi Naumov
*/
function testString(aVal ue)
{
/****
* This pattern will match
* only spaces between stock
* symbols and commas. If you
* use the \s shorthand
* character class this will
* be match "any white space".
*/
var re = /^\u0020*\w{1,5} \u0020*(?:,\u00 20*\w{1,5}\u002 0*)*$/;
return aValue.match(re ) != null;
}
Best regards.
On May 30, 10:48 am, Duncan Booth <duncan.bo...@i nvalid.invalid>
wrote:
billsahi...@yah oo.com wrote:
I cannot get anything to validate a comma delimited list of stock
symbols, like "IBM, MSFT,INTC). symbols are alphanumeric with a maxium
length of 5. I want to block multiple, adjacent commas, and allow up
to two blank spaces between symbols.
The following did not work:
(\w{1,5}(, *)?)*

It generally helps if you post what you actually tried and say exactly how
it failed to work. For example if you did:

/(\w{1,5}(, *)?)*/.test(somestrin g)

that will always evaluate to true because your expression matches an empty
string: you need to anchor it to the beginning and end of the string to do
any useful validation (and probably also you should insist on at least one
symbol). So something like this may be what you want:

/^\w{1,5}(?:,\s* \w{1,5})*$/.test(somestrin g)

On the other hand, if your problem was that:

/(\w{1,5}(, *)?)*/.exec('IBM, MSFT,INTC')

only saves the last of the symbols in a group then that would be a
misunderstandin g of how groups work.

May 30 '07 #5
On May 30, 11:00 am, Georgi Naumov <gonau...@gmail .comwrote:
Hi.
I hope this function will help you.
/**
* @author
* Georgi Naumov
*/
function testString(aVal ue)
{
/****
* This pattern will match
* only spaces between stock
* symbols and commas. If you
* use the \s shorthand
* character class this will
* be match "any white space".
*/
var re = /^\u0020*\w{1,5} \u0020*(?:,\u00 20*\w{1,5}\u002 0*)*$/;
return aValue.match(re ) != null;}

Best regards.
On May 30, 10:48 am, Duncan Booth <duncan.bo...@i nvalid.invalid>
wrote:
billsahi...@yah oo.com wrote:
I cannot get anything to validate a comma delimited list of stock
symbols, like "IBM, MSFT,INTC). symbols are alphanumeric with a maxium
length of 5. I want to block multiple, adjacent commas, and allow up
to two blank spaces between symbols.
The following did not work:
(\w{1,5}(, *)?)*
It generally helps if you post what you actually tried and say exactly how
it failed to work. For example if you did:
/(\w{1,5}(, *)?)*/.test(somestrin g)
I fixed the pattern. Because my english is not very well
i was miss "and allow up
to two blank spaces between symbols".
^\u0020*\w{1,5} \u0020*(?:,\u00 20*\w{1,5}\u002 0*)*$
This pattern will match "between 0 and unlimited numbers
of spaces". This is correct pattern:

^(?:\u0020{1,2} )?\w{1,5}(?:\u0 020{1,2})?(?:,( ?:\u0020{1,2})? \w{1,5}(?:
\u0020{1,2})?)* $
>
that will always evaluate to true because your expression matches an empty
string: you need to anchor it to the beginning and end of the string to do
any useful validation (and probably also you should insist on at least one
symbol). So something like this may be what you want:
/^\w{1,5}(?:,\s* \w{1,5})*$/.test(somestrin g)
On the other hand, if your problem was that:
/(\w{1,5}(, *)?)*/.exec('IBM, MSFT,INTC')
only saves the last of the symbols in a group then that would be a
misunderstandin g of how groups work.

May 30 '07 #6


On May 30, 11:00 am, Georgi Naumov <gonau...@gmail .comwrote:
- Hide quoted text -
- Show quoted text -
Hi.
I hope this function will help you.
/**
* @author
* Georgi Naumov
*/
function testString(aVal ue)
{
/****
* This pattern will match
* only spaces between stock
* symbols and commas. If you
* use the \s shorthand
* character class this will
* be match "any white space".
*/
var re = /^\u0020*\w{1,5} \u0020*(?:,\u00 20*\w{1,5}\u002 0*)*$/;
return aValue.match(re ) != null;}
Best regards.
On May 30, 10:48 am, Duncan Booth <duncan.bo...@i nvalid.invalid>
wrote:
billsahi...@yah oo.com wrote:
I cannot get anything to validate a comma delimited list of stock
symbols, like "IBM, MSFT,INTC). symbols are alphanumeric with a maxium
length of 5. I want to block multiple, adjacent commas, and allow up
to two blank spaces between symbols.
The following did not work:
(\w{1,5}(, *)?)*
It generally helps if you post what you actually tried and say exactly how
it failed to work. For example if you did:
/(\w{1,5}(, *)?)*/.test(somestrin g)
Thank you. It works.

I fixed the pattern. Because my english is not very well
i was miss "and allow up
to two blank spaces between symbols".
^\u0020*\w{1,5} \u0020*(?:,\u00 20*\w{1,5}\u002 0*)*$
This pattern will match "between 0 and unlimited numbers
of spaces". This is correct pattern:

^(?:\u0020{1,2} )?\w{1,5}(?:\u0 020{1,2})?(?:,( ?:\u0020{1,2})? \w{1,5}
(?:
\u0020{1,2})?)* $

May 30 '07 #7

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

Similar topics

16
3561
by: Sims | last post by:
Hi, I need some help to split data using regular expression Consider the string '1,2,3', I can split it using, preg_split("/,/", '1,2,3') and i correctly get =1, =2,=3. Now if i have
18
12344
by: MW | last post by:
Dear All Does anyone have a regular expression to parse a comma delimited line with some fields optionally having string delimiters (text qualifiers) I am currently testing with this regular expression and it works in almost all my test cases. I found this on the internet in a C# solution. ,(?=(*"*")*(?!*")) However in some of my test cases it fails and I am having difficulty
4
4870
by: Christine Forber | last post by:
I wonder if anyone knows of some javascript code to check a comma-delimited list of email addresses for basic formating. What I'm looking for is the javascript code to check a form field on form submission. If there is an entry in the field, does it match the following: text@text.text, text@text.text,text@text.text where each address is between commas and each address is in the format
1
4239
by: | last post by:
Hi, I have a Regular Expression that will match the format a user provides in a textbox. Ex. Brown,Joe in the textbox I would like the expression to have both whitespace and non-whitespace options after the comma.
3
3221
by: James D. Marshall | last post by:
The issue at hand, I believe is my comprehension of using regular expression, specially to assist in replacing the expression with other text. using regular expression (\s*) my understanding is that this will one or more occurrences to replace all the white space between with a comma. This search ElseIf InStr(1, indivline, "$") Then insert a replace statement that uses the regular expression to find and replace all the white space...
2
1832
by: Prakash | last post by:
Dear Friends, In my web application i have two textboxes to collect "ORIGIN" and "DESTINATION" stations. These stations are represented as three letter code.. We have an option like to provide multiple stations as seperated by comma(,) or slash(/) operator. Example Data Origin BOM, DEL,AUH
2
1551
by: billsahiker | last post by:
I am using the following to validate user input of a comma delimited list of stock symbols, separated by a comma and one or two spaces: ^(?:\u0020{1,2})?\w{1,5}(?:\u0020{1,2})?(?:,(?:\u0020{1,2})?\w{1,5}(?: \u0020{1,2})?)*$ It works, but I need to allow stock indices, which begin with ^ (ascii 94). How can I do that? sample input:
1
1312
by: rporter | last post by:
I have a javascript utility and need so help with regular expressions.. Basically I have lines of data that consists of name=value pairs delimited with commas. example match=type abc{0,4}D,search=(.*?) (.*?) (.*),replace=$2 $1 $3 The problem I have is sometimes as in the example a value may have a comma in it. In these cases in the value will be with a quoting mechinism, That include "value", 'value', (value), , and {value}.
0
9636
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...
1
10074
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,...
0
9930
tracyyun
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...
0
8961
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
7485
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
5373
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...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
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
3632
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.