• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Maybe it's too late
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Maybe it's too late


  • Subject: Re: Maybe it's too late
  • From: Lachlan Deck <email@hidden>
  • Date: Sat, 10 May 2008 04:01:35 +1000

Either of these would do...

public static boolean arrayContainsSubstring( NSArray< String > array, String substring )
{
if ( array == null || substring == null || array.count() == 0 )
return false;
return array .componentsJoinedByString ( "|" ).toLowerCase().indexOf( substring.toLowerCase() ) >= 0;
}


// or (perhaps more efficient)

public static boolean arrayContainsSubstring( NSArray< String > array, String substring )
{
if ( array != null && array.count() > 0 && substring != null )
{
String lowerSub = substring.toLowerCase();
for ( String item : array )
if ( item.toLowerCase().indexOf( lowerSub ) >= 0 )
return true;
}
return false;
}


with regards,
--

Lachlan Deck


On 10/05/2008, at 12:11 AM, Joshua Paul wrote:

Oh, I was referring to your substring routine...

On May 9, 2008, at 1:05 AM, Daniele Corti wrote:

2008/5/9 Joshua Paul <email@hidden>:
In this specific instance i was looking for intersecting strings from two arrays.


Nevertheless, I'm always curious to see how people solve various problems, so if you're willing to share, please pass along a code snippet.

NSArray first, second; //assume they exist and contian your strings

NSSet firstSet = new NSSet(first);
NSSet secondSet = new NSSet(second);
NSSet intersectingsSet = firstSet.setByIntersettingSet(secondSet);

NSArray myIntersectedArray = intersectingsSet.allObjects();


TIA.

On May 8, 2008, at 5:26 PM, Don Lindsay wrote:

Are you looking for a substring of a string in an array? Or are you looking for the whole string? I have written a routine to find the substring of a string in an array, if that would help.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Maybe it's too late
      • From: Joshua Paul <email@hidden>
References: 
 >Maybe it's too late (From: Joshua Paul <email@hidden>)
 >Re: Maybe it's too late (From: "Daniele Corti" <email@hidden>)
 >Re: Maybe it's too late (From: Miguel Arroz <email@hidden>)
 >Re: Maybe it's too late (From: David Avendasora <email@hidden>)
 >Re: Maybe it's too late (From: Joshua Paul <email@hidden>)
 >Re: Maybe it's too late (From: "Daniele Corti" <email@hidden>)
 >Re: Maybe it's too late (From: Don Lindsay <email@hidden>)
 >Re: Maybe it's too late (From: Joshua Paul <email@hidden>)
 >Re: Maybe it's too late (From: "Daniele Corti" <email@hidden>)
 >Re: Maybe it's too late (From: Joshua Paul <email@hidden>)

  • Prev by Date: Re: WO Tutorials install on windows
  • Next by Date: Re: WO Tutorials install on windows
  • Previous by thread: Re: Maybe it's too late
  • Next by thread: Re: Maybe it's too late
  • Index(es):
    • Date
    • Thread