Please, help me with program logic
Hi, I don't care. I'm fighting over this for the second day. Such a task: I have an integer list with some values, such as 65 and 87. And there is a string in which can be written at all anything, numbers, symbols, characters, letters, and so on, you need to check if this string contains the value from this list. I have no idea how to decide. Please help me
17 Replies
string.Contains()
In a loopa list can contain multiple values thou, so what exactly do you mean by "check if this string contains the value from this list"?
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Sorry for my bad English. I mean check whether the string contains only values from list
Integer values*
uh
so if your list is
[65,67]
and your string is 65x67
that would fail, because x
was in there?I can give a more clear example if you don't understand me.
please do
Look, I have an integer list. For example, it contains 65, 57, 85. And there is a string: "hei+6528/&9294-65=87%57z" need this string to be checked for whether it contains only numbers from list. Toot if there is something other than 65, 57, 85, in our case it is 6528, 9294 and 87, then returns false. Otherwise, if our line is approximately: "hei+*/&65=%57z", true
Now more clear?
ah okay
so you want to essentially extract all delimited integers from the string, and make sure all those exist in your list of integers
Yes
An excellent usecase for a parser
Can I just a little more?
I don't understand what we're talking about.
well, essentially you want to loop over the string, char by char
if its a number, add it to a buffer. if its not, yield the content of the buffer as an int, then clear the buffer
I think I'm starting to understand, a second, I need to check something
should print
Found 5 numbers: 6528, 9294, 65, 87, 57
if I understood you correct
then, instead of printing, we would just check if all the numbers exist in your list of integersFinally. Thank you very much for your time. You put me on the right thoughts I could find a solution myself. Thanks for working with me. Thank you very much
no problems