User input parsing

Joel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 14 00:14:43 PDT 2015


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;
			}



More information about the Digitalmars-d-learn mailing list