Click here to Skip to main content
15,913,159 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRegular expression!!! Pin
_AnsHUMAN_ 6-Nov-06 6:34
_AnsHUMAN_ 6-Nov-06 6:34 
AnswerRe: Regular expression!!! Pin
toxcct6-Nov-06 6:46
toxcct6-Nov-06 6:46 
QuestionRe: Regular expression!!! Pin
David Crow6-Nov-06 7:42
David Crow6-Nov-06 7:42 
AnswerRe: Regular expression!!! Pin
Chris Losinger6-Nov-06 8:49
professionalChris Losinger6-Nov-06 8:49 
QuestionRe: Regular expression!!! Pin
kakan6-Nov-06 19:21
professionalkakan6-Nov-06 19:21 
AnswerRe: Regular expression!!! Pin
_AnsHUMAN_ 6-Nov-06 19:32
_AnsHUMAN_ 6-Nov-06 19:32 
QuestionRe: Regular expression!!! [modified] Pin
kakan6-Nov-06 19:38
professionalkakan6-Nov-06 19:38 
GeneralRe: Regular expression!!! Pin
kakan6-Nov-06 20:28
professionalkakan6-Nov-06 20:28 
Hello again. I didn't receive an answer to my last question, but I made a solution that covers both cases.

You will have to adjust the code for Unicode if you want it.
And possibly adjust the code to ATL/STL if you want it.

Here goes:
The func:
<code>
void get(CString csIn, CString &csOut)
{
static CString csLast = "";
int lastLen = csLast.GetLength();

// Ignore and remove leading blanks in csIn.
while(csIn.GetAt(0) == ' ') csIn.Delete(0);
int inLen = csIn.GetLength();


if(inLen >= lastLen) {
// New, bigger value, save it.
csLast = csIn;
lastLen = csLast.GetLength();
}

int copyChars = lastLen - inLen;
if(copyChars > 0) {
csOut = csLast.Left(copyChars);
}
else csOut = "";

csOut += csIn;
csLast = csOut; // Save the last value for next time.
}
</code>

The main:
<code>
CString csRet;

get("31203", csRet); // csRet becomes "31203"
get(" 401", csRet); // csRet becomes "31401"
get(" 12", csRet); // csRet becomes "31412"
get(" 2110", csRet); // csRet becomes "32110"
get(" 4232", csRet); // csRet becomes "34232"

</code>

Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
GeneralRe: Regular expression!!! Pin
_AnsHUMAN_ 6-Nov-06 21:08
_AnsHUMAN_ 6-Nov-06 21:08 
GeneralRe: Regular expression!!! Pin
kakan6-Nov-06 21:12
professionalkakan6-Nov-06 21:12 
QuestionRe: Regular expression!!! Pin
David Crow7-Nov-06 2:52
David Crow7-Nov-06 2:52 
AnswerRe: Regular expression!!! Pin
kakan7-Nov-06 2:56
professionalkakan7-Nov-06 2:56 
QuestionExtract information from a List class (Win32 API question) Pin
Leprechaun786-Nov-06 6:03
Leprechaun786-Nov-06 6:03 
QuestionRe: Extract information from a List class (Win32 API question) Pin
David Crow6-Nov-06 7:38
David Crow6-Nov-06 7:38 
AnswerRe: Extract information from a List class (Win32 API question) Pin
Leprechaun786-Nov-06 23:22
Leprechaun786-Nov-06 23:22 
GeneralRe: Extract information from a List class (Win32 API question) Pin
David Crow7-Nov-06 2:49
David Crow7-Nov-06 2:49 
GeneralRe: Extract information from a List class (Win32 API question) Pin
Leprechaun787-Nov-06 3:55
Leprechaun787-Nov-06 3:55 
GeneralRe: Extract information from a List class (Win32 API question) Pin
David Crow7-Nov-06 4:03
David Crow7-Nov-06 4:03 
GeneralRe: Extract information from a List class (Win32 API question) Pin
Leprechaun788-Nov-06 2:16
Leprechaun788-Nov-06 2:16 
GeneralRe: Extract information from a List class (Win32 API question) Pin
David Crow8-Nov-06 2:47
David Crow8-Nov-06 2:47 
GeneralRe: Extract information from a List class (Win32 API question) Pin
Leprechaun788-Nov-06 3:15
Leprechaun788-Nov-06 3:15 
Questionpuzzled by the following calss defination Pin
cy163@hotmail.com6-Nov-06 3:31
cy163@hotmail.com6-Nov-06 3:31 
AnswerRe: puzzled by the following calss defination Pin
Cedric Moonen6-Nov-06 3:37
Cedric Moonen6-Nov-06 3:37 
GeneralRe: puzzled by the following calss defination Pin
led mike6-Nov-06 4:24
led mike6-Nov-06 4:24 
GeneralRe: puzzled by the following calss defination Pin
Cedric Moonen6-Nov-06 4:38
Cedric Moonen6-Nov-06 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.