Powershell : I want to restrict the "variables" a user puts into my textbox. from a list if possible?

I have a textbox with 3 customfields where the user can put in whatever he wants, and its parsed as answer.

Now I want to restrict it to a wordlist like that for my first input :

Question 1 : How old are you ?  
Answer (User input)  : `1-99`   (digits)

For my second question I need Answers combined of 2 Wordlists, like :

Question : Whats your mothers name ?

Assuming now that I have 2 List with possible names: All names of the world and all male names . So now I need to read out all names possible and subtract the other list. (Allnames.txt - allmalenames.txt) = Answer2

So the user can only put in female names in the end, and no I don't have female list first ;)

With that information i can resolve question 3 alone I guess :)

My Code is basicially this input box from the powershell tips of week. Custom input box Any help is upvoted fast. If anything is unclear, let me know.

Answers


$answer2 = <user input string>
$allnames = <path to all names file>
$malenames = <path to male names file>

if (
     ( Select-String -Path $allnames -Pattern "^$answer2$" -Quiet ) -and -not
     ( Select-String -Path $malenames -Pattern "^$answer2$" -Quiet )
   )

  { Do whatever needs done if it is a female name }

 else { Do whatever needs done if it is not a female name }

returns $true, $answer2 is a valid female name. Otherwise, not.


Need Your Help

What is the fastest way to parse text with custom delimiters and some very, very large field values in C#?

c# parsing bulk delimited-text

I've been trying to deal with some delimited text files that have non standard delimiters (not comma/quote or tab delimited). The delimiters are random ASCII characters that don't show up often be...

Best way to test for existing string against a large list of comparables

c# regex string compare

Suppose you have a list of acronym's that define a value (ex. AB1,DE2,CC3) and you need to check a string value (ex. "Happy:DE2|234") to see if an acronym is found in the string. For a short list of