Find String

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have two arrays of strings, s1 and s2:

s1 = "london, lisbon, paris, newyork"

s2 = "lisbon, yellow, France"

s2 will have only one item included in s1.

I want to find which item is it. In this case is lisbon.

How can I do this?

Thanks,

Miguel
 
Split one of the string to a string array with the Split() method and then
try to find the array items in another string one by one.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net


I have two arrays of strings, s1 and s2:
s1 = "london, lisbon, paris, newyork"
s2 = "lisbon, yellow, France"
s2 will have only one item included in s1.
I want to find which item is it. In this case is lisbon.
How can I do this?

Miguel

I just made the 2 string arrays using split.
Isn't there a function to get the common elements to the two string
arrays?
I would then get the only value which is common to both string arrays.

Shouldn't this be better than using a for loop and test each string?

Thanks,
Miguel
 
Not that I know. The foreach loop will consist of only one IndexOf call.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


shapper said:
Split one of the string to a string array with the Split() method and
then
try to find the array items in another string one by one.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net


I have two arrays of strings, s1 and s2:
s1 = "london, lisbon, paris, newyork"
s2 = "lisbon, yellow, France"
s2 will have only one item included in s1.
I want to find which item is it. In this case is lisbon.
How can I do this?

Miguel

I just made the 2 string arrays using split.
Isn't there a function to get the common elements to the two string
arrays?
I would then get the only value which is common to both string arrays.

Shouldn't this be better than using a for loop and test each string?

Thanks,
Miguel
 
Back
Top