Skip to content

Instantly share code, notes, and snippets.

@bearcherian
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bearcherian/66ea0b163cd95c4484b8 to your computer and use it in GitHub Desktop.
Save bearcherian/66ea0b163cd95c4484b8 to your computer and use it in GitHub Desktop.
import std.stdio;
import std.regex;
import std.array;
import std.conv;
void main(string[] args)
{
if (args.length < 1)
{
writeln("No string specified");
}
writeln("Enter the string: ");
string input = readln();
writeln("Enter indexes to return (space delmited)");
string indexes = readln();
string[] index = split(indexes);
string[] words = split(input,regex("[^a-zA-Z0-9]+"));
foreach(int i, string idx; index)
{
auto x = to!int(idx);
if ( x > 0 && x < words.length)
{
write(words[x]," ");
}
}
writeln("");
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment