1

I need to verify if a string format has correct number and position of parameters. In my system advanced users (administrators) can configure a option with string format and select the params in combobox, one specific combobox to position in format. To save I need verify if this configuration is correct.

This is to generate a unique code to a record, this code is specific for each client.

In my screen I have a text box to the format, that can contain up to 6 items (or less), for each item i have one combobox. The comboboxes contains a type of the value (ex. sequence, year, number, nothing (in case it's not required, etc). I need verify if the format is correctly (ex. {0}-{1} is correct and {0}-{1}.{3} is wrong) and respective comboboxes are selected (ex. {0}-{1} require select a type in combobox 0 and 1)

--update--

I have resolved this question verifing the number of parameters in the string format is match with the number of values selecteds and the order of the values selecteds (ex. if the user keep any value empty and selected the next I have assumed this is incorrect) and I try generate a string with the format and values informed

3
  • Well, you can extract all {xx} patterns from your string and then check is something selected or not according to the xx value. It's hard to suggest more without seeing your code and clear undersnanding what's going on at your side. Commented May 25, 2015 at 14:57
  • Why is {0}-{1}.{3} incorrect? Perhaps he wants to ommit the 3rd parameter value? Commented May 25, 2015 at 17:38
  • In this case he can select the 4th parameters as 3rd. Using format {0}-{1}.{2} and selecting the parameter on the respective combobox. My idea is simplify for the user Commented May 25, 2015 at 17:43

1 Answer 1

1

To match a string to a particular pattern you should look into Regular Expressions.

It looks however, like there is more to it than simply pattern messaging - like maybe the user should be able to specify the desired pattern at run time? The question is a little unclear to be honest so I don't understand your full requirement.

Sign up to request clarification or add additional context in comments.

2 Comments

If you don't understand OP's full requirement (frankly, I don't fully understand it) - then it's better to ask for clarification in comments. Right now you "answer" in fact doesn't answers OP's question at all and much more looks like a comment than answer.
Well if he's just looking for match with a static question, the first line answers his question perfectly. Given the OP is a little unclear, that may be all he/she needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.