Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Compare 2 strings for similar items

Participant ,
Aug 18, 2010 Aug 18, 2010

I have 2 strings  --String A and String B

String A  (1,2,3,4,5,6,7,8)

String B (1,2,3,4,9,10,11,12)

I need to compare the 2 strings and find the values that ARE IN BOTH strings.

So the answer I need to get is 1,2,3,4 as 1,2,3,4 is in BOTH strings.

I cant find anything in the CF String Functions.

Any Ideas?

523
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Aug 18, 2010 Aug 18, 2010

There are different ways to slice it. But a general approach is to loop through one of the lists. Then for each element, use list functions (ie listFindNoCase, etcetera) to determine if it exists in the other list as well. If it does, append the value to a variable. At the end of the loop, you will have a list of elements contained in both lists.

Having said that, cflib.org is always a good place to check first.

http://cflib.org/udf/ListInCommon

Translate
Valorous Hero ,
Aug 18, 2010 Aug 18, 2010
LATEST

There are different ways to slice it. But a general approach is to loop through one of the lists. Then for each element, use list functions (ie listFindNoCase, etcetera) to determine if it exists in the other list as well. If it does, append the value to a variable. At the end of the loop, you will have a list of elements contained in both lists.

Having said that, cflib.org is always a good place to check first.

http://cflib.org/udf/ListInCommon

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources