The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Extracting numeric part of a string

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hajo_old Posted - 11/06/2003 : 10:54:49 AM
Hello, all

I would like to examine a string whether some characters are numeric (0-9) or alphabetic (a-z, A-Z).

Some examples .. "A203", "AB35", "BC208"
The goal is, to extract only the numeric part of the strings.
I thought of somthing similar to RegExp ... Any other suggestions to detect the numeric part of a string?

Is there a chance to get that in OriginC or with the help of Labtalk?

Thanks
Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1

Edited by - SVDO_Origin1 on 11/06/2003 10:57:38 AM

Edited by - SVDO_Origin1 on 11/06/2003 2:17:46 PM
1   L A T E S T    R E P L I E S    (Newest First)
hajo_old Posted - 11/07/2003 : 04:12:56 AM
Hello, all

found a sollution - maybe there's a better one (comments wellcome!)
but it's working!

// extract numeric part of Excel Cell strings
// "AB665", "A678", "E6"
// ATTENTION straightforward function, does it's job,
// but is NOT FAILSAFE (e.g. for "A34B56") !!
UINT getNumeric(string s)
{
int index = strcspn( s, "0123456789" );
s = s.Right(s.GetLength()-index);
printf("num: %s\n", s);
return atoi(s);
}


Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000