Re: Maybe it's too late
Re: Maybe it's too late
- Subject: Re: Maybe it's too late
- From: Joshua Paul <email@hidden>
- Date: Sat, 10 May 2008 15:14:56 -0700
I likey. :-)
Thanks!
On May 9, 2008, at 11:01 AM, Lachlan Deck wrote:
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.
--
Josh Paul
email@hidden
twitter: joshpaul
linkedin: joshpaul
NOTICE: This e-mail message and all attachments transmitted with it
are intended solely for the use of the addressee and may contain
legally privileged and confidential information. If the reader of this
message is not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, you
are hereby notified that any dissemination, distribution, copying, or
other use of this message or its attachments is strictly prohibited.
If you have received this message in error, please notify the sender
immediately by replying to this message and please delete it from your
computer.
_______________________________________________
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