Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
.contains() vs .icontains() (Read 720 times)
Sumner Gerard
Full Member
*
Offline



Posts: 359

.contains() vs .icontains()
Aug 04th, 2016, 3:17pm
 
I am having trouble understanding when to use .contains() and when to use .icontains() in an agent query when looking for matches in a string (in my case $Text or $Name).

Part of my confusion stems from the existence of the 'Case insensitive' checkmark in inspector, which I just assumed could apply to a query where I was using .contains().

I understand (from message off-forum) that .contains() is always case sensitive and that icontains() should be used for case insensitive.

Is that the only difference between the two?
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: .contains() vs .icontains()
Reply #1 - Aug 4th, 2016, 3:50pm
 
Now that we have .contains() and .icontains() , the case-sensitive boxes they're effectively there for legacy reasons only (and for folks who just won't change their style). I'd leave them in the default position and never touch them again. What's the default? Open a new doc and look at the relevant bit of the UI. For old docs, I'd reset those controls and update actions to use the new dot operators. So...

.contains() does a case-sensitive test. So $MyString.contains("Dog") will match 'Dog' but not 'dog' or 'DOG', etc.  Every character in the tested string and match must be the same case.

.icontains() does a case-insensitive test. So $MyString.icontains("Dog") will match 'Dog' and 'dog', 'DOG', etc. Indeed it will match the sequences of letters d, o and g in any case combination.

It's that's simple.

TB's around 15 years old and under gradual improvement all that time, so some stuff has stuck around. I'd put the case-sensitivity boxes in that group. Still, if removed it would cause a few long term users problems and I'm sure the developer doesn't relish the sort of support calls that sort of situation would generate.  Shocked
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Sumner Gerard
Full Member
*
Offline



Posts: 359

Re: .contains() vs .icontains()
Reply #2 - Aug 4th, 2016, 4:05pm
 
Thanks, Mark.  So the "i" stands for (case) "insensitive" ... and leave those legacy boxes (and presumably the AgentCaseSensitive attribute) alone!
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print