AutoSpin c#

  • Thread starter Thread starter Deleted member 156403
  • Start date Start date
D

Deleted member 156403

Guest
Right guys here is my problem, I am trying to make a autospinner using a database of words to match agasint words in a string.How can i add brackets around each word within a string along with the | and the opposite word..

for example if I have a var called theString with the string "Hello world my name is mintuz" How could I add { } around each word along with the or bracket and a possible word read from the database. so it reads...

"{Hello | Hi} {world | Univerise} {my} {name | ID} {is | may be } {mintuz}"
 
You need to add the brackets on the code side. I don't believe you can add those brackets in SQL and if you can it's most likely more trouble than it's worth.
 
if I understand what you're looking for then something along these lines should work...

Code:
string target = "Hello world my name is mintuz";
string[] words = target.Split(' ');
StringBuilder result = new StringBuilder();

foreach (var word in words)
{
    // Perform your replacement word search
    string word2 = ...;
    result.AddFormat("{{{0} | {1}}} ", word, word2);
}
return result.ToString();

That should give you something close to what you're looking for. I typed this straight into the reply box, so there may be a typo there... but the logic works. And you won't need any regex to make it work.

Hope this helps.
 
Back
Top