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
80
votes
3 answers

How to use regex in XPath "contains" function

I would like to match the following text sometext12345_text using the below regex. I'm using this in one of my selenium tests. String expr = "//*[contains(@id, 'sometext[0-9]+_text')]"; driver.findElement(By.xpath(expr)); It doesn't seem to work…
ragesh
  • 975
  • 1
  • 9
  • 12
77
votes
2 answers

What is the idiomatic scala way of finding, if a given string contains a given substring?

I have two strings in scala and I want to find out, if the bigger string (needle) contains a smaller string (haystack). What I found is doing it with regexps and matches like this (from this…
Karel Bílek
  • 36,467
  • 31
  • 94
  • 149
75
votes
4 answers

jQuery :contains selector to search for multiple strings

Assuming i have:
  • Mary
  • John, Mary, Dave
  • John, Dave, Mary
  • John
  • If i need to find all
  • Elements which contain "John" and "Mary", how would i construct the jQuery? A search for a…
  • zıəs uɐɟəʇs
    • 1,728
    • 3
    • 14
    • 27
    74
    votes
    7 answers

    Pandas: Check if row exists with certain values

    I have a two dimensional (or more) pandas DataFrame like this: >>> import pandas as pd >>> df = pd.DataFrame([[0,1],[2,3],[4,5]], columns=['A', 'B']) >>> df A B 0 0 1 1 2 3 2 4 5 Now suppose I have a numpy array like np.array([2,3]) and…
    Robin
    • 8,197
    • 11
    • 45
    • 74
    73
    votes
    9 answers

    Check if an ArrayList contains every element from another ArrayList

    There is probably a simple one-liner that I am just not finding here, but this is my question: How do I check if an ArrayList contains all of the objects in another ArrayList? I am looking (if it exists) for something along the lines…
    Evorlor
    • 7,263
    • 17
    • 70
    • 141
    72
    votes
    8 answers

    Check if a variable is in an ad-hoc list of values

    Is there a shorter way of writing something like this: if(x==1 || x==2 || x==3) // do something What I'm looking for is something like this: if(x.in((1,2,3)) // do something
    user1854438
    • 1,784
    • 6
    • 24
    • 30
    72
    votes
    10 answers

    C# enum contains value

    I have an enum enum myEnum2 { ab, st, top, under, below} I would like to write a function to test if a given value is included in myEnum something like that: private bool EnumContainValue(Enum myEnum, string myValue) { return…
    Fred Smith
    • 2,047
    • 3
    • 25
    • 36
    72
    votes
    4 answers

    How can I tell if a VARCHAR variable contains a substring?

    I thought it was CONTAINS, but that's not working for me. I'm looking to do this: IF CONTAINS(@stringVar, 'thisstring') ... I have to run one select or another, depending on whether that variable contains a string and I can't figure out how to…
    Yatrix
    • 13,361
    • 16
    • 48
    • 78
    71
    votes
    10 answers

    Fastest way to check if a List contains a unique String

    Basically I have about 1,000,000 strings, for each request I have to check if a String belongs to the list or not. I'm worried about the performance, so what's the best method? ArrayList? Hash?
    Ben
    • 1,657
    • 4
    • 16
    • 21
    66
    votes
    8 answers

    Check if element is in the list (contains)

    I've got a list of elements, say, integers and I want to check if my variable (another integer) is one of the elements from the list. In python I'd do: my_list = [1,2,3,4] # elements my_var = 3 # my variable my_var in my_list # returns boolean How…
    ducin
    • 25,621
    • 41
    • 157
    • 256
    63
    votes
    9 answers

    What is the linq equivalent to the SQL IN operator

    With linq I have to check if a value of a row is present in an array. The equivalent of the sql query: WHERE ID IN (2,3,4,5) How can I do it?
    Luca Romagnoli
    • 12,145
    • 30
    • 95
    • 157
    62
    votes
    6 answers

    What does Collection.Contains() use to check for existing objects?

    I have a strongly typed list of custom objects, MyObject, which has a property Id, along with some other properties. Let's say that the Id of a MyObject defines it as unique and I want to check if my collection doesn't already have a MyObject object…
    topwik
    • 3,487
    • 8
    • 41
    • 65
    61
    votes
    12 answers

    Check if a string exists in an array case insensitively

    Declaration: let listArray = ["kashif"] let word = "kashif" then this contains(listArray, word) Returns true but if declaration is: let word = "Kashif" then it returns false because comparison is case sensitive. How to make this comparison…
    Kashif
    • 4,642
    • 7
    • 44
    • 97
    60
    votes
    10 answers

    Add items to a collection if the collection does NOT already contain it by comparing a property of the items?

    Basically, how do I make it so I can do something similar to: CurrentCollection.Contains(...), except by comparing if the item's property is already in the collection? public class Foo { public Int32 bar; } ICollection
    michael
    • 14,844
    • 28
    • 89
    • 177
    60
    votes
    5 answers

    C++ implicit copy constructor for a class that contains other objects

    I know that the compiler sometimes provides a default copy constructor if you don't implement yourself. I am confused about what exactly this constructor does. If I have a class that contains other objects, none of which have a declared copy…
    Jamison Dance
    • 19,896
    • 25
    • 97
    • 99