Justinas Justinas - 10 days ago 6
C# Question

Remove from text words made of different symbols

Hey guys im new here and i need to make my program to remove all words from txt file which are made of different symbols. I dont even know where to start.
PS.
Sorry for my English. :)

public int Imti(char sim)
{
return Rn[sim];
}
public void kiek()
{
for (int i = 0; i < eil.Length; i++)
{
if (('a' <= eil[i] && eil[i] <= 'z') || ('A' <= eil[i] && eil[i] <= 'Z'))
Rn[eil[i]]++;
}
}
static void Spausdinti(string fv, RaidziuDazniai eil)
{
using (var fr = File.CreateText(fv))
{
string[] lines = File.ReadAllLines(fv, Encoding.GetEncoding(1257));

for (char sim = 'a'; sim <= 'z'; sim++)
fr.WriteLine("{0,3:c} {1,4:d} |{2,3:c} {3,4:d}", sim, eil.Imti(sim), Char.ToUpper(sim), eil.Imti(Char.ToUpper(sim)));
}
}
static void Dazniai(string fv, RaidziuDazniai eil)
{
using (StreamReader reader = new StreamReader(fv))
{
string line;
while ((line = reader.ReadLine()) != null)
{
eil.eil = line;
eil.kiek();
}
}


this is what i made before

To clarify what the OP is asking: He wants to remove words from a string that have the same character 2 or more times. For example, "test" should be removed because it has 2 t's.

Answer

Adapt this here to your needs, output holds all distinct character words:

const string test =
"this is a test text consisting of various words where some consist of unique characters only while others have duplicates in them.";

var words = test.Split(' ');
var output=new List<string>();
foreach (var word in words)
{
    if (word.Distinct().Count() == word.Length) // word contains distinct characters only
    {
        output.Add(word);
    }
}
Debug.Print(string.Join(" ",output));