Skip to content
Advertisement

compare two comma separated strings and list the common values

How many I compare the two comma separated list (master and input) and list the common values among them (result) while preserving the order of elements in master list. For example:

case1:

JavaScript

case 2:

JavaScript

case 3:

JavaScript

This is what I tried:

JavaScript

Advertisement

Answer

Here is one awk-oneliner solution:

JavaScript

Test with your 3 cases:

Case 1

JavaScript

Case 2

JavaScript

Case 3

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement