Any method to ignore spaces in Rust in statements with if/else or similar?

My I/O program searches for specific words? but when searching for others or several of them, the if/else conditionals is automatically drops "not found" (behavior programmed by myself btw) during the scanning program should ignore spaces. Is there a method to implement this?

Can you provide an example of the behaviour you want? It's a bit hard to follow what you're trying to say.

It may not be what you're looking for, but I have used a method chain (String Value).trim().replace(" ", "").to_lowercase() to normalize strings for comparison to ignore beginning/ending whitespace, spaces, and letter case. This creates a new String rather than mutates in place, so there's likely a more efficient way, but it works.