#Separating|Decoding 1 Line
62 messages · Page 1 of 1 (latest)
a:123;b:456;c:789;id:c11ba3#2b#a
a is a letter that represents the number sequence 123
after id I need to look at every alphabet and replace each alphabet with whichever number sequence it is represented by
this question was just asked like, a couple hours ago maybe?
was that you? did you delete the original? I don't see it
haha yea it was somebody else in my study group, however we are still stuck at this step after trying to figure it out for hours
there are quite a few ways to approach this kind of thing
this sounds academic and somewhat arbitrary
so a naive approach is probably fine
meaning, you could go all the way into parser and compiler theory for this kind of stuff, but you probably don't need to
a simple approach would be basically just do a bunch of string splits
first split on ; and then split each of those on :
finally do a basic std::regex replace on the last value
Noobie here, but he could also use a map
sure?
map with a-z keys and int value
nothing I said implies what storage destination type to use exactly
Not implying that either just saying you're the more experienced one
this assignment is on string manipulation, so we were trying to go about it with vectors
but we arent experienced with them so we arent sure what functions we can use or how the syntax would work
a map would probably be the natural container choice for the initial key value pairs
we are not too familiar with what a map is, is it something I could easily look up and learn? or is it more complex
I mean, I don't know what functions you can use either
Well, you could have one vector containing a-z
And the other has the same size but the index number is the alphabet number
meaning, idk if your course or professor has restrictions
without restrictions, everything you need is in stdlib
it doesnt
were welcome to utilize whatever we find on the internet so long as credit is given
std::getline and various functions in <regex> and <string> all will get you where you need to go
browse the docs on cppreference.com and see what's available
i thought getline was for when u had parameters to go by?
I don't think that matters here
^
it's an academic/school project
speed does not matter atm
yes, homework assignment
Well fair enough
bad doggo is probably giving the better idea but also check std::map if you have extra time
Might be useful
ngl tho this is a nice course
We had to reinvent the wheel on ours 💀
Multiple times
were not sure how to implement the vector functions in our for loop
so our idea is wanting to use substr to categorize the information between : and ;
we have this
but were not sure whether that would work because id is also an alpha, so were trying to go about it with the colons
What is the isalpha
its checking for an alphabetic character
we've written a bit more to narrow it down
vector <char> letter; would be the 'a' and the vector <string> decoder would be the '123' or numbers associated with it
I need to sleep, hope someone else can help
i appreciate your help and ideas with the different function ideas
You're welcome! Best of luck
@karmic edge
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.
@karmic edge
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.