C
cpp_weenie
Given a std::string of the form "default(N)" where N is an integer number of
any length (e.g. the literal string might be "default(243)"), what is the
quickest way to extract the characters representing the integer into another
std::string? In the example above, I'd want to end up with a std:string
whose value is "243".
The substrings "default(" and ")" are invariant - they're always present in
the string I have to work with. Furthermore, it is guaranteed that there
will be at least one numeric character between the open and close
parentheses, and it is also guaranteed that there will be nothing but
numeric characters between the open and close parentheses.
I'm looking for the shortest possible standard-compliant and safe way of
making this substring extraction. (Yes, "shortest" and "quickest" as I've
used them here are subjective measures, but I'm sure people will intuitively
get the idea of what I'm trying to accomplish.)
any length (e.g. the literal string might be "default(243)"), what is the
quickest way to extract the characters representing the integer into another
std::string? In the example above, I'd want to end up with a std:string
whose value is "243".
The substrings "default(" and ")" are invariant - they're always present in
the string I have to work with. Furthermore, it is guaranteed that there
will be at least one numeric character between the open and close
parentheses, and it is also guaranteed that there will be nothing but
numeric characters between the open and close parentheses.
I'm looking for the shortest possible standard-compliant and safe way of
making this substring extraction. (Yes, "shortest" and "quickest" as I've
used them here are subjective measures, but I'm sure people will intuitively
get the idea of what I'm trying to accomplish.)