Skip to content

string_digits

CryoEagle edited this page Dec 26, 2018 · 4 revisions

string_digits

Returns a copy of a given string with everything but its digits removed.

Syntax:

string_digits(str)
Argument Description
string str The string to get the digits from.

Returns: string

Description

You can use this function to parse a given string and get any numbers from it. For example, say you have this text - "I am 81 years old". With this function you would get a return string of "81".

Example:

string str1 = "We have 64 eggs";
string str2 = string_digits(str1);
int eggs = real(str2);

The above code will take the str1, strip it of all characters other than numbers and then set the variable "eggs" to hold the real number value of the return string.

Back to strings

Clone this wiki locally