I am writing a app in .NET which will generate random text based on some input. So if I have text like "I love your {lovely|nice|great} dress" I want to choose randomly from lovely/nice/great and use that in text. Any suggestions in C# or VB.NET are welcome.
I am writing a app in .NET which will generate random text based on
Share
You could do it using a regex to make a replacement for each
{...}. TheRegex.Replacefunction can take aMatchEvaluatorwhich can do the logic for selecting a random value from the choices:Example output:
Update: Translated to VB.NET automatically using .NET Reflector: