in reply to compare two strings and return only he unique values.
Note:
The various solutions posted above don't behave exactly the same. This is because the OP hasn't described the problem very precisely, so the commenters (myself included) have made implicit assumptions about the intended meaning of "unique values from two strings".
Interpreting the term "values" in that quote as characters, there are at least two different meanings:
-
Characters that appear exactly once in one of the strings, and don't appear in the other.
This is what the above solutions by blue_cowdawg and Not_a_Number do.
-
Characters that appear one or more times in one of the strings, and don't appear in the other.
This is what the above solutions by tobyink and myself do.
If "values" is supposed to mean something other than individual characters, simply adapt any of the above solutions by replacing the split(//, ...) calls with a statement that tokenizes the string into a list of values in the intended way.
In case the strings are not intended to be tokenized in a fixed way, but instead what you are looking for is arbitrary text fragments that appear in one of the strings, but don't appear in that same spot in the other, look into Algorithm::Diff