contains

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

穿精又带淫゛_ 提交于 2019-12-10 12:38:11
问题 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 get the list of the words contained in the text, something like that: List<string> matches = myText.findWords(words) 回答1: There is no special analysis in this query except you have to use Contains method. So you may try this:

Stack in Java, problem with “contains”

不羁的心 提交于 2019-12-10 10:27:03
问题 I'm using stack in my program but I have a problem when program is trying to check what element contains in stack. I'm using array of integer in Stack. Short example is: Stack<int[]> myStack = new Stack<int[]>(); myStack.push(new int[]{1,2}); myStack.push(new int[]{1,3}); myStack.push(new int[]{1,4}); if (myStack.contains(new int[]{1,3})) { System.out.println("YES"); } else { System.out.println("NO"); } Now it was printed "NO". How could I do to get "YES" ? I know that the problem is that I'm

Java containsAll does not return true when given lists

妖精的绣舞 提交于 2019-12-10 10:06:46
问题 I want to check an array is subset of another array. The program prints false, but I expect true. Why isn't containsAll returning true? int[] subset; subset = new int[3]; subset[0]=10; subset[1]=20; subset[2]=30; int[] superset; superset = new int[5]; superset[0]=10; superset[1]=20; superset[2]=30; superset[3]=40; superset[4]=60; HashSet sublist = new HashSet(Arrays.asList(subset)); HashSet suplist = new HashSet(Arrays.asList(superset)); boolean isSubset = sublist.containsAll(Arrays.asList

Does char array contain string?

↘锁芯ラ 提交于 2019-12-10 09:21:40
问题 I have a text file and would like to check if it contains a string. The text file is stored in a char array: char buffer[512][128]; . Q1: Is it easier if I buffer it in one long array instead of a multidimensional array? Q2: How could I check whether the buffer contains the string char *s1 = "Hello world!"; ? I will need to search for multiple strings. 回答1: It will be much easier to use a single 1D array. strstr(buffer, s1) != null (once you've changed buffer into a 1D array) 回答2: strstr 来源:

Delete nodes with certain value from XML using TSQL

南笙酒味 提交于 2019-12-10 03:39:33
问题 I'm trying to parse a piece of XML and remove nodes that contain certain values. I know how to remove them if the value is exact, but I want to use something like a "contains". This works to delete exactly: update @XML set data.modify('delete //Message[text() = "customer has deleted their account"]') But I want to delete where the "Message" node just contains the text, something like: update @XML set data.modify('delete //Message[contains(text(), "customer")]') However this returns the error:

How to use Python 'in' operator to check my list/tuple contains each of the integers 0, 1, 2?

我与影子孤独终老i 提交于 2019-12-09 12:09:51
问题 How do I use the Python in operator to check my list/tuple sltn contains each of the integers 0, 1, and 2? I tried the following, why are they both wrong: # Approach 1 if ("0","1","2") in sltn: kwd1 = True # Approach 2 if any(item in sltn for item in ("0", "1", "2")): kwd1 = True Update: why did I have to convert ("0", "1", "2") into either the tuple (1, 2, 3) ? or the list [1, 2, 3] ? 回答1: if ("0","1","2") in sltn You are trying to check whether the sltn list contains the tuple ("0","1","2")

Syntax error near 'of' in the full-text search condition 'control of'

痞子三分冷 提交于 2019-12-09 04:20:20
问题 I have the following WHERE clause: WHERE (@Keywords IS NULL OR (CONTAINS((p.Title, p.Area, p.[Message]), @Keywords)) ) If @Keywords = 'control' , then the query executes successfully and filters my records If @Keywords = 'control of' , then I get the following error: Syntax error near 'of' in the full-text search condition 'control of'. Why is this and what can I do to resolve the issue? The main reason I'm using this method over using LIKE condition is so that I can search multiple words.

how can I check if a structure is in the array of structures based on its field in Swift3?

一世执手 提交于 2019-12-09 03:24:41
问题 In my swift app I have a structure: open class MyStruct : NSObject { open var coordinate = CLLocationCoordinate2D(latitude: 0, longitude: 0) open var username: String? = "" open var id: String? = "" } And I create an Array of it: var array:[MyStruct] = [] Then I'm creating an object: let pinOne = MyStruct() pinOne.coordinate = CLLocationCoordinate2D(latitude: request.latitude, longitude: request.longitude) pinOne.username = request.username pinOne.id = request.id and I want to add it to the

Best way to use contains in an ArrayList in Java?

▼魔方 西西 提交于 2019-12-09 03:06:33
问题 I have an ArrayList in Java which is made up of a type containing two strings and an integer. I can successfully test if one element of this ArrayList equals another but I find that the contains method fails. I believe this is due to the fact that my type is not primitive. Now I see two alternatives to this and I wonder which is the best option: To implement my own contains method by iterating through the ArrayList and testing equality of each element against the one I'm looking for and then

jquery script adding id and using it doesn't work

為{幸葍}努か 提交于 2019-12-08 19:34:14
问题 i am trying to use my keyboard to click on a button using the id. For some buttons i had to set the ID, which actually works. But as soon as i try to use the keyboard for the buttons where i set the id, it won't work. I am not getting any errors and since adding the id to the element works, i am kinda confused why i cannot use the new set id later in the code. //setting id for first button (works) $( "a:contains('Im Verband freigeben')" ).attr('id', 'freigabe-verband'); //setting id for