On Wednesday, 14 October 2015 at 07:14:45 UTC, Joel wrote:
Is there a fast way to get a number out of a text input?

Like getting '1.5' out of 'sdaz1.5;['.

Here's what I have at the moment:
                        string processValue(string s) {
                                string ns;
                                foreach(c; s) {
                                        if (c >= '0' && c <= '9')
                                                ns ~= c;
                                        else if (c == '.')
                                                ns ~= '.';
                                }

                                return ns;
                        }

What about "sdaz1.a3..44["?

Anyway, you could use an appender, or reserve memory to speed up your code.

Reply via email to