Reputation: 597
Is it possible given 2 strings to get the difference using regular expressions. The length of the examples can vary. For example now it's only Id, Name, and Age. However, it could happen that for other examples they include additional properties. So they could be Id, Name, Age, Occupation, Address, etc. For example I have
example1:
"Id = xcv-sd234-2 \n
Name = joe \n
Age = 32 \n"
example2:
"Id = xcv-sd234-2 \n
Name = Chloe \n
Age = 32 \n
Occupation = driver"
Desired outcome:
"Name = Chloe \n
Occupation = driver"
Upvotes: 0
Views: 45
Reputation: 2407
Split on new line character and compare strings for strict equality (however you do that in Java). Shouldn’t even need regex for that.
Upvotes: 1