Oct 20, 2019 at 8:14pm UTC
i was learning string parsing using c++.
i came across a problem where there are many delimiters and specific string needs to be selected from the given successive line
input was like this ans we need to filter computer name , date and connection status from it .
[0BBB] ComputerName:Acer UserID:A90 Laua Lon Station 9 LanId: | (12/21 12:30:49) | Client disconnected.
[0BBB] ComputerName:Samsung UserID:A01 Laua Long Station 9 LanId: | (12/21 12:30:54) | Client connected.
and many more strings
please can anyone help in how to separate computer name, date and connection status from these successive strings.
Last edited on
Oct 20, 2019 at 8:15pm UTC
Oct 20, 2019 at 9:45pm UTC
if you have that whole thing as one string, you can use repeated calls to find() to locate the keywords and then pull out what is between keywords or spaces or whatever the back side delimiter is using a substring.
Oct 21, 2019 at 5:03am UTC
String parsing and/or separation is usually done in (1) split function, or (2) regular expression.
> split (boost library)
probably, delimiter (eCompress argument) is set correctly, you get what you want.
> regex (C++11, it is standard library)
Regular expression is a little confusing, but after you are familiar with it, you can handle more situation than the above.
Last edited on
Oct 21, 2019 at 5:08am UTC
Oct 21, 2019 at 9:10am UTC
thank you for your help , those stl functions were very helpful.