Hi, I'm using VS2008 MFC VC++ and trying to get dynamic numbers from a string and paste them into another string.
Let's say there is a dialog and get the window caption as String A:
String A (input string):
Voltage: 2.0V, Current:0.4A, Resistance: 5.0Ω, Power: 1.5W.
String A is also a dynamic input. It could be
Voltage: 30V, Current:1.2A, Resistance: 25Ω, Power: 36W.
or next time could be
The apple is inside column: 12, row: 3, box: 5.
For String B, it is exactly the same as String A except the numbers are replaced by delimiter. It is used as the reference to extract the numbers from String A.
String B (input reference string):
Voltage: %fV, Current:%fA, Resistance: %fΩ, Power: %fW.
Then this is String C,
String C (output reference string):
The answers are %fV; %fA; %fΩ; %fW.
Therefore, how can I extract the 4 sets of number and paste them into String C and get the final output as
The answers are 2.0V; 0.4A; 5.0Ω; 1.5W.
From my understanding on
regex, is the String B (input reference string) will be the pattern that used to search/match the String A? Any idea?
Thanks.
What I have tried:
I tried to implement the split and merge method but it seems not possible for this situation because there are too much possibility from the input string.