Click here to Skip to main content
15,884,967 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am working on a web-portal where my customer can order several products. The product are delivered in a multiple of 1000, 500 and 250. For a multiple of 1000, i have a code (below). For a multiple of 250 and 500, i don't have a code. Can you help me with that?

I use \d*000$ for a multiple of 1000..

I am searching for a code of multiples of 250 and 500

What I have tried:

I use \d*000$ for a multiple of 1000..

I am searching for a code of multiples of 250 and 500
Posted
Updated 29-May-16 22:32pm
Comments
Richard MacCutchan 30-May-16 3:36am    
What sort of code are you talking about? You say this is for a web portal, but you have tagged your question C++. Please edit your question and show some real code that demonstrates what you are trying to do.
Member 12554033 30-May-16 3:37am    
Sorry, i am talking about Regex
Sergey Alexandrovich Kryukov 30-May-16 3:43am    
The idea of using Regex is wrong, in this case, no matter what you do (the question is not correctly formulated).

Can I assume that you have a text input, and when you use the data entered by the user, you want to check up (validate) the input; it should be some numeric count, multiples of 250, 500, etc.? If so, do exactly that. First, parse it as integer, and if it is parsed, take this integer and check up the value.

—SA
Sergey Alexandrovich Kryukov 30-May-16 3:37am    
Sorry, the code is not created by "searching". You need to write this code, using first principles.
What have you tried so far?
—SA
Member 12554033 30-May-16 3:40am    
To be honest, i have tried a little. I am using software wich provide me with a box to put in a code to validate with Regex

Instead of text box, use option controls like dropdown list or radio buttons.
Radio Button or Drop Down List? · Formstack Blog[^]
Google on how to create these web UI.
 
Share this answer
 
v2
Comments
Member 12554033 30-May-16 4:47am    
This is an option that works for me. Only when the product is available in quantities of 40.000, the dropdown list is to large
Peter Leow 30-May-16 4:57am    
You cited an example "The envelopes come in order of 250 samples in a box. When you order 300, the site wil not accept it. Only a multiple of 250 samples.."
My question is why do you allow users to enter invalid number like 300 (with or without knowing that each box must contain 250 samples). If there are certain fix quantity in each box of product, state it upfront, then the users only need to enter the number of boxes that he/she want.
What do you think?
Member 12554033 30-May-16 5:29am    
That is Right. Ik Think that is possible. The codes in solution 1 workes fine for me
To start with, if you want to work with Regexes, then get a copy of Expresso[^] - it's free, and it examines and generates Regular expressions.

In this case try:
\d*(0{3}|250|500|750)$
Or
\d*(000|250|500|750)$
 
Share this answer
 
v2
Comments
Member 12554033 30-May-16 4:46am    
Great! Solution 1 works for me. Only for a multiple of 500 it doesn't
OriginalGriff 30-May-16 5:02am    
Strange: I checked it in Expresso for all of them.
What values did you check for 500's?
Member 12554033 30-May-16 5:30am    
Ik have already solved it with: \d*(0{3}|500)
OriginalGriff 30-May-16 5:43am    
Ah! I see what you mean! :laugh:
Member 12554033 30-May-16 5:31am    
Thank you very much!

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