Need help on Regular Expression

P

Prakash

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
Destination LON,BKK

Now the requirement is,
a) Duplicate stations are not allowed in Origin and Destination fields.
Ex.. Origin - BOM, BOM, DEL, AUH, Del
b) Same Stations are not allowed in both Origin and Destination
Ex.. Origin - BOM, DEL, AUH
Destination - AUH, LON, BKK

I hope, it is possible with Regular expressions. But i don't have idea
about how to achieve using regular expression.

Please advice me to solve the issue using regular expression or some
other way.

Regards,
Prakash
 
F

Frans Bouma [C# MVP]

Prakash said:
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
Destination LON,BKK

Now the requirement is,
a) Duplicate stations are not allowed in Origin and Destination
fields. Ex.. Origin - BOM, BOM, DEL, AUH, Del
b) Same Stations are not allowed in both Origin and Destination
Ex.. Origin - BOM, DEL, AUH
Destination - AUH, LON, BKK

I hope, it is possible with Regular expressions. But i don't have idea
about how to achieve using regular expression.

Please advice me to solve the issue using regular expression or some
other way.

Regular Expressions are expressions to identify parts in a string and
eventually change them with teh rudimentary functions build into
regex's.

So the best thing you can do I think is use a regex to get all the
3-letter codes and use a hashtable to check if a match is already in
the list or not (add a found match to the keys of the hashtable with a
value null and you can fast check if a 3-letter match has been found by
simply call ContainsKey)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
P

Prakash

Thanks FB

eventually change them with teh rudimentary functions build into
regex's.

So the best thing you can do I think is use a regex to get all the
3-letter codes and use a hashtable to check if a match is already in
the list or not (add a found match to the keys of the hashtable with a
value null and you can fast check if a 3-letter match has been found by
simply call ContainsKey)

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website:http://www.llblgen.com
My .NET blog:http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------- Hide quoted text -- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top