determine the range of a alphanumeric string separated by hyphen?

evolet10000

Active member
Joined
Nov 22, 2012
Messages
40
Programming Experience
Beginner
ok so i have a string value like this fac00029170-75A


what i need to do is to determine the range separated by hyphen(-)
in the example fac00029170-75A what i need is like this


fac00029170,
fac00029171,
fac00029172,
fac00029173,
fac00029174,
fac00029175


any suggestions? i already search the web and they suggest using contain(), substring and split... but i just cant figure out on how i will do this.. ant help will be appreciated thank you:D
 
You're hardly going to find examples of doing exactly that. You would find examples of string manipulation and it would then be up to you to pick out the parts of those that are useful and put them together to solve your particular problem. That's what examples are for, not to copy and paste and fix your problem without additional effort.

Here are the steps I would perform:

1. Determine the prefix, i.e. the letters before the number, and set that aside.
2. Remove the letters from the beginning and end.
3. Split the remaining string on the dash.
4. Create a copy of the first part and replace the same number of digits at the end with those digits from the second part.
5. Convert those two strings into numbers.
6. Use a loop to create the numeric range and add the prefix to each.

This is how you do software development: break your original problem into smaller sub-problems and then solve each of those problems. Put all the smaller solutions together and you have inherently solved the original problem. Each of the steps above will take no more than a few lines of code each so should be relatively easy to solve.
 
hi, sorry if the question sounds like i want a copy paste code. but its not. just want some advice. The steps that you gave is exactly what i need...ill try to crack it out using those steps.. thank you:D
 
hi, sorry if the question sounds like i want a copy paste code. but its not. just want some advice.

I wasn't saying that. I was saying that you were probably searching for too broad an idea to find anything that seemed specifically relevant. Breaking the problem down into its constituent parts is usually an important first step because the more basic the problem you're trying to solve, the more likely you are to find a specifically relevant example or even solution. :)
 
Back
Top