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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Extracting numeric part of a string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hajo_old

Germany
141 Posts

Posted - 11/06/2003 :  10:54:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

hajo_old

Germany
141 Posts

Posted - 11/07/2003 :  04:12:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000