Questions tagged [contains]

The "contains" operator/method is used to determine if an entity collection contains an element with a particular property.

The contains operator/method is used to determine whether one (or more) of the entities in an entity collection has a particular property.

3008 questions
26
votes
4 answers

jQuery if "this" contains

I'm trying to change any elements containing a particular text string to a red color. In my example I can get the child elements to become blue, but there's something about the way I've written the 'Replace Me' line that is incorrect; the red color…
Chris
  • 463
  • 2
  • 6
  • 16
25
votes
4 answers

With Scala's Set, is there a method analog to the containsAll method in Java's Set?

While working through converting some Java code over to Scala, I discovered while there is a contains method for Scala's Set, there isn't a containsAll method. Am I just missing the correct method name? Here's a bit of code I worked up to fill in…
chaotic3quilibrium
  • 5,661
  • 8
  • 53
  • 86
25
votes
6 answers

How to use Linq to check if a list of strings contains any string in a list

I'm constructing a linq query that will check is a string in the DB contains any of the strings in a list of strings. Something like. query = query.Where(x => x.tags .Contains(--any of the items in my list of strings--)); I'd…
Lrayh
  • 1,281
  • 2
  • 13
  • 15
24
votes
3 answers

Functionality of Python `in` vs. `__contains__`

I implemented the __contains__ method on a class for the first time the other day, and the behavior wasn't what I expected. I suspect there's some subtlety to the in operator that I don't understand and I was hoping someone could enlighten me. It…
joshua.r.smith
  • 917
  • 2
  • 8
  • 19
24
votes
9 answers

Using SQLServer contains for partial words

We are running many products search on a huge catalog with partially matched barcodes. We started with a simple like query select * from products where barcode like '%2345%' But that takes way too long since it requires a full table scan. We thought…
Guy Korland
  • 9,139
  • 14
  • 59
  • 106
23
votes
5 answers

Select div (or other element) that class contains "grap" (o other specified word) for example

First of all; example of HTML code:
some conetent
some conetent
some conetent
some content>
And now i want to select divs that class contains "grap"…
born2fr4g
  • 1,290
  • 4
  • 27
  • 38
23
votes
3 answers

mongoose — check if ObjectId exists in an array

Following is an example model: UserModel == { name: String, friends: [ObjectId], } friends corresponds to a list of id of objects of some other model for example AboutModel. AboutModel == { name: String, } User.findOne({name: 'Alpha'},…
p0lAris
  • 4,750
  • 8
  • 45
  • 80
23
votes
6 answers

Determine if all characters in a string are the same

I have a situation where I need to try and filter out fake SSN numbers. From what I've seen so far if they are fake they're all the same number or 123456789. I can filter for the last one, but is there an easy way to determine if all the…
Jhorra
  • 6,233
  • 21
  • 69
  • 123
22
votes
5 answers

If classlist contains more than one specific class

I need a function to trigger if the element recordplayerstick contains either the pinplace or pinsongplay class. The code I currently have returns a syntax error. What is the correct way to do this? if…
user9951515
  • 265
  • 1
  • 2
  • 9
22
votes
1 answer

Using contains filter in DynamoDB scan with Java

Suppose I have a working query such as: ScanRequest scanRequest = new ScanRequest() .withTableName("myTable") .withFilterExpression("attr1 = :val1 and attr2 = :val2") .withExpressionAttributeValues(vm) //contains…
user3146897
  • 541
  • 1
  • 5
  • 15
22
votes
4 answers

Tell if string contains a-z chars

I very new to programming. I want to check if a string s contains a-z characters. I use: if(s.contains("a") || s.contains("b") || ... { } but is there any way for this to be done in shorter code? Thanks a lot
user2276872
22
votes
3 answers

Comparing object used as Key in Dictionary

my class: public class myClass { public int A { get; set; } public int B { get; set; } public int C { get; set; } public int D { get; set; } } and main example: Dictionary> dict = new Dictionary
Saint
  • 5,397
  • 22
  • 63
  • 107
22
votes
4 answers

xpath to select nodes excluding by attribute value list

I would like to know if there is shorter approach to selecting a list of nodes ignoring the ones that have an attribute value specified in a list Working example: /item[not(@uid='id1') and not(@uid='id2')] Desired alternative: /item[not(@uid…
Aitorito
  • 235
  • 1
  • 2
  • 5
21
votes
6 answers

Selectively disable subsumption in Scala? (correctly type List.contains)

List("a").contains(5) Because an Int can never be contained in a list of String, this should generate an error at compile-time, but it does not. It wastefully and silently tests every String contained in the list for equality to 5, which can never…
Shelby Moore III
  • 6,063
  • 1
  • 33
  • 36
21
votes
5 answers

jquery val() contains()

I want to know if the textarea value contains a certain word. This is not working for me. var value = $('#embedModal textarea').val(); if($(value).contains('iframe')){...
Hussein
  • 42,480
  • 25
  • 113
  • 143