Legion
Legion
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
I think i might fixed it i did it like this:
C#
public static string NormalizeString(string str)
{
return Regex.Replace(str, @"[^a-zA-Z0-9]", "").ToLower();
}

var matchingElements = htmlDataArray
.Where(htmlItem =>
{
// Normalize both html and text data to remove unnecessary characters
string normalizedHtmlItem = NormalizeString(htmlItem);
bool matchFound = txtDataArray.Any(txtItem =>
NormalizeString(txtItem).Equals(normalizedHtmlItem, StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
// Normalize and get the corresponding match
string normalizedHtmlItem = NormalizeString(htmlItem);
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
NormalizeString(txtItem).Equals(normalizedHtmlItem, StringComparison.OrdinalIgnoreCase));

// Log the match
Console.WriteLine($"'{htmlItem}' matched with '{matchingLine}'");

return matchingLine; // Return the matched line
})
.Where(matchingLine => !string.IsNullOrEmpty(matchingLine)) // Filter out null or empty matches
.Select(item => item + ";") // Append a semicolon to each matched element
.ToArray();
C#
public static string NormalizeString(string str)
{
return Regex.Replace(str, @"[^a-zA-Z0-9]", "").ToLower();
}

var matchingElements = htmlDataArray
.Where(htmlItem =>
{
// Normalize both html and text data to remove unnecessary characters
string normalizedHtmlItem = NormalizeString(htmlItem);
bool matchFound = txtDataArray.Any(txtItem =>
NormalizeString(txtItem).Equals(normalizedHtmlItem, StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
// Normalize and get the corresponding match
string normalizedHtmlItem = NormalizeString(htmlItem);
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
NormalizeString(txtItem).Equals(normalizedHtmlItem, StringComparison.OrdinalIgnoreCase));

// Log the match
Console.WriteLine($"'{htmlItem}' matched with '{matchingLine}'");

return matchingLine; // Return the matched line
})
.Where(matchingLine => !string.IsNullOrEmpty(matchingLine)) // Filter out null or empty matches
.Select(item => item + ";") // Append a semicolon to each matched element
.ToArray();
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
Where would i put that in this code ?
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
yes
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
So basicly txt - list of mods on server. html - list of mods for current mission. get the list of mods from html and txt compare them and only output the list of mods that are in txt that match the html list of mods.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
No i just want it to output the mods on server txt
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
Ok so this is my code currently: https://pastebin.com/yjeAYvw2 So my matchingElements string array is getting filled with only with a first element in ServerMods .txt how would i go and get all of the mods that mached in that array ?
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
Ok yea i was using diffrent normalize. Now the only problem i am facing is that the output string is basicly getting spamed with first element in serverMods:
c#
var matchingElements = htmlDataArray
.Where(htmlItem =>
{
bool matchFound = txtDataArray.Any(txtItem =>
htmlItem.NormalizeTest().Equals(txtItem.NormalizeTest(), StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.NormalizeTest().Equals(txtItem.NormalizeTest(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem;
})
.Select(item => item + ";")
.ToArray();
c#
var matchingElements = htmlDataArray
.Where(htmlItem =>
{
bool matchFound = txtDataArray.Any(txtItem =>
htmlItem.NormalizeTest().Equals(txtItem.NormalizeTest(), StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.NormalizeTest().Equals(txtItem.NormalizeTest(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem;
})
.Select(item => item + ";")
.ToArray();
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
No description
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
So i tried doing this:
C#
var matchingElements = htmlDataArray
.Where(htmlItem =>
{
bool matchFound = txtDataArray.Any(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem;
})
.Select(item => item + ";")
.ToArray();
C#
var matchingElements = htmlDataArray
.Where(htmlItem =>
{
bool matchFound = txtDataArray.Any(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"Checking '{htmlItem}' -> Match Found: {matchFound}");
return matchFound;
})
.Select(htmlItem =>
{
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem;
})
.Select(item => item + ";")
.ToArray();
And it returns like this: Checking 'CBA_A3' -> Match Found: False Checking 'ace' -> Match Found: False Checking 'Enhanced Movement' -> Match Found: False Checking 'KAT - Advanced Medical' -> Match Found: False Checking 'Enhanced Movement Rework' -> Match Found: False Checking 'DUI - Squad Radar' -> Match Found: False Checking 'Task Force Arrowhead Radio (BETA!!!)' -> Match Found: False Checking '3den Enhanced' -> Match Found: False Checking 'Better Inventory' -> Match Found: False Checking 'cTab NSWDG Edition' -> Match Found: False Checking 'Better CAS Environment (BCE)' -> Match Found: False Checking 'Zeus Enhanced' -> Match Found: False Checking 'BackpackOnChest - Redux' -> Match Found: False Checking 'Ghost recon 3rd Person Camera' -> Match Found: False Checking 'Immerse' -> Match Found: False Checking 'Suppress' -> Match Found: False Checking 'RHSAFRF' -> Match Found: False Checking 'RHSUSAF' -> Match Found: False Checking 'RHSGREF' -> Match Found: False .... But there should be there.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
So matchingElemts is: matchingElements {string[0]} string[] And Outputstring is null But output string should just be collecion of matchingElements joined with ;
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
I tried to do it like this:
C#
var matchingElements = htmlDataArray
.Where(htmlItem => txtDataArray.Any(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase)))
.Select(htmlItem =>
{
// Find the matching text file line
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem; // Use the matching line or keep the HTML item
})
.Select(item => item + ";") // Add a semicolon at the end of each item
.ToArray();
C#
var matchingElements = htmlDataArray
.Where(htmlItem => txtDataArray.Any(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase)))
.Select(htmlItem =>
{
// Find the matching text file line
var matchingLine = txtDataArray.FirstOrDefault(txtItem =>
htmlItem.Normalize().Equals(txtItem.Normalize(), StringComparison.OrdinalIgnoreCase));
return matchingLine ?? htmlItem; // Use the matching line or keep the HTML item
})
.Select(item => item + ";") // Add a semicolon at the end of each item
.ToArray();
But i have error: Value cannot be null. Parameter name: text C:\Users\jorda\source\repos\TestConsole\TestConsole\bin\Debug\TestConsole.exe (process 24124) exited with code 0 (0x0). To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
How would i do that sry i am still new to coding 😄 ?
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
No here are couple of examples i mange to catch that are diffrent: HTML:
@LAMBS_Danger.fsm;
@E.P.S.M ExoMod Remastered;
@ WIP Anti-Bounce System ABS ;
@Hyper Realistic Ragdoll Vanilla.ver ;
@RE: RHS Escalation;
@Reduced Haze Mod v3.1;
@LAMBS_Danger.fsm;
@E.P.S.M ExoMod Remastered;
@ WIP Anti-Bounce System ABS ;
@Hyper Realistic Ragdoll Vanilla.ver ;
@RE: RHS Escalation;
@Reduced Haze Mod v3.1;
Server Mods:
@LAMBS_Dangerfsm
@EPSM ExoMod Remastered
@[WIP] Anti-Bounce System ABS
@Hyper Realistic RagdollVanillaver
@RE RHS Escalation
@Reduced Haze Mod v31
@LAMBS_Dangerfsm
@EPSM ExoMod Remastered
@[WIP] Anti-Bounce System ABS
@Hyper Realistic RagdollVanillaver
@RE RHS Escalation
@Reduced Haze Mod v31
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
That would be fine but There are just to diffrent to compare like some mods have () some dont.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
Yea basicly i am asking what would be best aproach to this.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
I cant match with the hole name becouse in Html file the mods is called like this: @LAMBS_Danger.fsm But on the server is called like this: @LAMBS_Dangerfsm And there are couple of mods that dont mach the nameing convetion. Basicly i was comparing them with the name in html and geting the value name from server mod.
59 replies
CC#
Created by Legion on 1/20/2025 in #help
Compare Strings better way.
Here is also Server mods txt and Modpack html:
59 replies