troubleshooting Question

compare strings ignore \n and whitespace

Avatar of ICPooreman
ICPooreman asked on
JavaScript
2 Comments1 Solution632 ViewsLast Modified:
I want to compare two strings like below.

string test = "This is a Test";
string test2 = "\n       \n           \n This is a Test                 \n"

if(test == test2){
   //do something
}

I'm assuming I can strip the newlines and whitespace somehow and this will work but I'm not sure.
ASKER CERTIFIED SOLUTION
Zvonko
Systems architect
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros