FAQ Database Discussion Community


Regex/Java. Match words with 'aa' sequence

java,regex,contains
Hi im looking for a regex command for matching words with only 2 letters 'a' or 'A'. Single 'a' is ok but when word contains 3 or more 'a' next to each other its wrong. GAASSCC - good EAAASCS - bad AAASDAA - bad ASBSAA - good...

Element is present but `Set.contains(element)` returns false

java,hash,set,contains,hashset
How can an element not be contained in the original set but in its unmodified copy? The original set does not contain the element while its copy does. See image. The following method returns true, although it should always return false. The implementation of c and clusters is in both...

Is there a way to write generic code to find out whether a slice contains specific element in go?

go,slice,contains
I want to know is there a generic way to write code to judge whether a slice contains a element, I find it will frequently useful since there is a lot of logic to fist judge whether specific elem is already in a slice and then decide what to do...

how to replace a word with in contains() Method form a JtextPane

java,swing,user-interface,replace,contains
Well, I'm trying to replace a word by using contains() Method: String z = tfB.getText().toString(); String show = textPane.getText().toString(); if(show.contains(z)){ // how I specify the word that were found and change it without effecting anything with in that line } well what I main by that: What I'm trying to...

Why does this loop throw a System.ArgumentOutOfRangeException error, rather than ending?

c#,loops,arraylist,contains
Why my loop can not end? Why does it throw an exception instead? int i=0; ArrayList item = new ArrayList(); ArrayList list = new ArrayList(); while (reader.Read()) { item.Add(reader["element"].ToString());//keep data from my SQL } string chk2 = textBox1.Text.ToString(); for ( i = 0; i <= item.Count;i++ ) { if ((item[i].ToString()).Contains(chk2)...

Entity framework return items from list that not contained in a table

entity-framework,list,contains
I am new using entity framework i have a list of form numbers and i want to search from a table for that list of form numbers and then return form numbers from the list that not contains in the table i tried this query it gave me half of...

Java Linked List .contains method

java,list,equals,contains
I have a LinkedList containing elements of type A. I need to check whether the list contains an element based on some criteria. Is it enough to override the .equals method in class A, or do I need to override the hash method as well?...

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

java,scala,set,contains
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 the gap so I could...

Pandas Python: Delete Rows of DF That Have ASCII Letters

python,pandas,dataframes,contains,letters
I have a column in my dataframe that I would like to convert to datatype int. However it is throwing an error because some of the rows have letters in their entries. I would like to create a new dataframe that only has entries in this column with pure numeric...

Performance of IndexOf(char) vs Contains(string) for checking the presence of a character in a string

c#,string,contains,indexof
I want to know if string.IndexOf(char) is faster than string.Contains(string). Intention is to check if a single character is present in a string. I know that as per requirement I should use string.Contains(string) but that is not the point of this question. I did try to disassemble mscorlib.dll in an...

Alternative to .Contains in linQ and subqueries

vb.net,linq,subquery,contains
I'm having issues with .Contains method in linQ. It gives dramatic results :( There are many threads but not in vb.net and I'm kind of lost Let's say I have 2 datatables in my dataset : -The first keeps a TREE structure (could be seen as this) : Category (.id="1")...

How can I check if an ArrayList contains an Object with a specific field value?

java,arraylist,override,equals,contains
I have an ArrayList of Objects. I want to see if that ArrayList contains an Object with a particular field. TeamBuilder.java public class TeamBuilder { public static void main(String[] args) { Team team = new Team(); team.addMember(new TeamMember("myID")); System.out.println(team.containsMember("myID")); //false } } TeamMember.java public class TeamMember { private String id;...

jQuery contains doesn't work on chrom

javascript,jquery,contains
I have one problem with jquery contains. It work perfect on firefox. This is my code. $("input[data-height='cm']").blur(function(){ var text = $(this).val(); if($(this).val().length > 0) { if(!$(this).val().contains("cm")) { $(this).val(text + " cm"); } } }); on chrome it give error Uncaught TypeError: $(...).val(...).contains is not a function How can I fix...

Python String - Passing parameter to .__contains__ from a list

python,string,list,contains
I have a list of strings like so: filterlist = ["Apple", "Banana", "Cherry"] I want to loop through this and check if any one of these strings is present as part of another string like test_str = "An Apple a day keeps the Doctor away" This is what I tried...

How to clean some some strings in the list?

python,string,contains,startswith
I am trying to remove some strings from a list when the string starts with or contains "@", "#", "http" or "rt". A sample list is below. text_words1 = [[email protected]', 'haberci', '#sorumlubenim', 'dedigin', 'tarafsiz', 'olurrt', [email protected]', 'saysaniz', 'olur', '#sorumlubenim', 'korkakligin', 'sonu'] According to above list, I want to remove [email protected]'...

C# Contains don't work's with “\”

c#,contains
Well, It's a noob question... I'm trying to use: if (string.Contains("\")) { return false; } But I receive the message: Newline in constant How I can use this method to detect "\" in a string?...

can't use contains in swift2 using xcode 7

contains,swift2
I am using swift2. I used this code: while contains(currentCardValues, randomNumber + 1){ I am getting this error: "contains" is unavailable: call the 'contains() method on the sequence ' ...

VB - If StreamReader reads line containing (“string1”) but missing (“string2”)

vb.net,string,contains
EDIT: How would I go about retrieving the filename of the files that meet said conditions? How I can check if a string contains "value1" but doesn't have "value2"? I tried this: While Not sr.EndOfStream Dim sLine As String = sr.ReadLine If sLine.Contains("value1") Then If Not sLine.Contains("value2") Then sw.WriteLine("write name...

Check if a string contains a list of substrings and save the matching ones

c#,string,contains
This is my situation: I have a string representing a text string myText = "Text to analyze for words, bar, foo"; And a list of words to search for in it List<string> words = new List<string> {"foo", "bar", "xyz"}; I'd want to know the most efficient method, if exists, to...

XSLT contains error

xml,xslt,foreach,contains
I apologize for the crude explanation, I'm fairly new to xml and xslt. Thanks for your patience. Here's the challange, I'm trying to build a transformation to csv that creates a new line for each instance of an employee's benefit enrollments. So, if they're enrolled in two plans, a line...

Check if a string contains a character ignoring case

c#,string,contains
I have a textbox on GUI which takes an "Mobile Number" as input. I want to validate it to find out if it has some characters, which would mean the number is invalid So, a number 9876543210 is valid while a number 98765df013 is invalid I made a array of...

Where list contains any in List

c#,asp.net-mvc,linq,contains,any
I am just sending this data to reporting Engine(SSRS) in Asp.net MVC5. Everything is fine, but this query is taking a lot of time since I have to loop through ListProducts (I guess ListProducts is the size of the database matches). I am just looking for a way to optimize...

Get elements containing text from array

javascript,jquery,html,arrays,contains
I want to search all the elements containing any string in the array. For example I have following list of items <ul> <li>cricket bat</li> <li>tennis ball</li> <li>golf ball</li> <li>hockey stick</li> </ul> and this array var arr = ['bat', 'ball']; It should select all the elements having text bat and ball....

unexpected behaviour of Google BigQuery WHERE NOT list CONTAINS string

sql,google-bigquery,contains
I have a small example table temp.ty: From this table I want to only extract the rows where ipc is not present in not_ipc (and where exclude is not present in other_classes), which seems rather straigtforward. Yet the following query returns zero results: SELECT * FROM temp.ty where not ipc...

Will I loose performance with many SQL CONTAINS command instead of only one?

sql-server-2012,contains
I'm implementing a command with full-text search on SQL Server and I'm having problems to build a dynamic query like this: CONTAINS (MyTable, [email protected] AND @param2 AND NOT @param3') So I found an alternative making a sequence of CONTAINS command, like this: CONTAINS (MyTable, @param1) AND CONTAINS (MyTable, @param2) AND...

JS var inside query does not work when stringed together

javascript,jquery,contains
I have the following code which is really bloated $(".field-name-field-parts-status .field-item:contains('Submitted'), .field-name-field-parts-status .field-item:contains('Saved'), .field-name-field-parts-status .field-item:contains('HMNZ Approved')").addClass('btn-primary'); I tried to neaten it up by adding a var var fieldItemStatus = $(".field-name-field-parts-status .field-item"); So it looked like this $(fieldItemStatus + ":contains('Submitted'), " + fieldItemStatus + ":contains('Saved'), " + fieldItemStatus + ":contains('HMNZ...

using if statements in tableau on a contains function

if-statement,contains,tableau
Say I have city populations for each state / city in the united states. I want to mark each city with over 2 million population as a big city. then if a state contains a "big city", i want to mark that state as a "big state". I made a...

List of Strings - Odd Behavior

java,java.util.scanner,contains,string-concatenation
I'm working on an obscenity filter for a random word generator so that it avoids certain words or phrases. The code is fairly simple so far and I'm using some test words to try it out, yet there is already a strange error occurring that makes absolutely no sense to...

Is inside range

range,contains,nim,nimrod
Say you have the following type: type Min = 1..4 You want to check whether some int falls inside Min as you can with sets: 's' in {'a'..'z'} It is possible to express it more elengantly than: 2 in {low(Min)..high(Min)} #Too many characters 2 in Min #Expecting this conciseness ...

find elements wich id contains two substrings

javascript,jquery,substring,contains
I have a HTML table and I need change the css style to all de <td> whose "id" contains the substring "_A_189" and the substring "_B_V_852" using jquery. The substrings could be in any position of the string. I use this, but it doen't work: $('id:contains("_A_189"):contains("_B_V_852")').css(style); ...

Java contains() not in accordance with equals()

java,equals,contains
I have a custom class with overriden equals() and hashCode() methods. I store instances of that class in a TreeSet. I cannot figure out why the tree.contains(someObject) returns true, while tree.first().equals(someObject) returns false, in the case when the tree has only one element.

BigQuery - filtering without losing 'null' values

null,google-bigquery,contains
I try to filter a database but unluckily I lose the 'null' values either way: The Sample looks like Name | City | Sold Nike | NYC | 15 null | SFO | 20 Mega | SEA | 10 null | null | 8 nike | CHI | 12 I...

Check if string contains a list of strings in any order

c#,string,linq,contains
Basically, I have a list of products and a search option. When multiple words are searched I want to return any product which contains all words searched in any order. So if a user searches "green shirt", the returned list would include "green t-shirt large", "t-shirt green medium", etc. My...

How to get a char sequence from String that contains a searched string

java,string,char,contains
I would like to know if their is a function in JAVA that allows to retrieve from a huge string a char sequence that contains a special char. Example: I have a php page that that I've stringified and I check if there is a char sequence containing the char...

Excel - See if cells in one column contain text from another

excel,search,contains,lookup
Currently I am using the below to see if cells in column B exist in Column A... =IF(ISERROR(MATCH(B1,A:A,0)),"False","True") ... However I've just realised the need to not check for an exact match, but rather if the cells in column B contain text that appear in any of the cells in...

How can for HashSet h and element e hold: h.contains(e) != new HashSet<>(h).contains(e)?

java,collections,contains
In Java 8, I have a HashSet h (correctly typed by generics), with hashCode/equals methods implemented up to the bottom of the type hierarchy - apparently correctly as eclipse did it for me. In some (rare) cases, the method invokation h.contains(e) returns false - which is wrong (to my understanding)...

Exclude label tags that have input type=“radio” child nodes using Xpath

html,xml,xpath,contains
When parsing the source code of https://www.gov.uk/contact/govuk I want to be able to filter out the label tags that have input type="radio" as child nodes using Xpath. I've been trying a variety of solutions like the following: $labels = $xpath->query('//label[not(contains(@type, "radio"))]'); $labels = $xpath->query('//label[not(contains(input[@type], "radio"))]'); Neither of which seems to...

objective-C - add commas to CONTAINS condition in NSPredicate

objective-c,core-data,nspredicate,contains
Here is the situation. I have some Core Data data and I want to get the data where a certain column (type) contains a variable. But not just the variable, it has to be: ,variable, This is my current code: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"type CONTAINS ',%@,'", typeBar]; That doesn't...

Error implementing __contains__ (in) for a Python class

python,class,contains
I am trying to implement contains such that it can be used for any of several attributes in my python object. I was able to successfully implement "==" and most of the other comparison operators, but "in" is giving me problems: import operator class Comparator: def __init__(self,fieldName,compareToValue,my_operator): self.op = my_operator...

Java: Determining if a word contains letters that can be found in another word?

java,string,contains
For example: If you have a String "magikarp", and you tested it against "karma", this would be true, because all of the letters that make up "karma" can be found in "magikarp". "kipp" would return false, because there is only one "p" in "magikarp." This is the attempt that I...

EF linq Find in list where objectA.prop1 is any of objectB.prop2

c#,linq,entity-framework,contains,any
I have some question about a linq query I cannot manage to do. It's matter of finding objects Consider the List (ListA), where i want to select all rows where the value of field F20 is in a list (ListB). For each of these items, i will then replace the...