Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Experts,

I am getting some data from textboxes these data these data can be any one from the below fromat:-

400vs0102-0103
400-vs-0102-103
400-vs0102-103


The data i need is:-

400-vs-0102/0103


Thanks in Advance
Posted
Comments
Andy Lanng 30-Apr-15 7:46am    
Looks like an idea might be to remove the dashes and rebuild the string each time.
Will it always be nnn-ll-nnnn/nnnn (n=[0-9], l=[a-z] or event nnn-vs-nnnn/nnnn?
Sergey Alexandrovich Kryukov 30-Apr-15 10:33am    
First of all, imagine the user who is required to type all this gibberish in a text box. Why? Isn't it the abuse in first place, where you design UI and/or data formats? It could be 3 separate numbers, maybe a selection of something from the list, and so on...
What have you tried so far?
—SA

1 solution

If this format is fixed, you can use a masked text box.
Alternately, parse the first three characters, check for an hyphen in the fourth location and if not present, add one.
Similarly, put one in the 7th position if it is not there.

If the length of the text is variable then it becomes much harder to build a solution.
Unless you have some specific tags to search on, you will not be able to build a generic solution.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 30-Apr-15 10:33am    
5ed.
—SA
Abhinav S 30-Apr-15 10:52am    
Thank you.
Maciej Los 30-Apr-15 15:00pm    
Agree with Sergey, 5!
Abhinav S 30-Apr-15 15:18pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900