search

Sort CoreData results using NSPredicate in Swift

扶醉桌前 提交于 2019-12-18 15:09:09
问题 I'm currently writing a simple phone book app in Swift and need to sort the results from a CoreData query. Basically, I set up an NSManagedObject called "Directory", with the appropriate field names in - e.g. "name_f" is the user's name. The names in the CoreData database that is queried are in alphabetical order. However, although the first search returns the results in alphabetical order, further searches sometimes aren't after the database has been queried by other areas of the program. I

Python Regular Expressions, find Email Domain in Address

倾然丶 夕夏残阳落幕 提交于 2019-12-18 14:37:07
问题 I know I'm an idiot, but I can't pull the domain out of this email address: 'blahblah@gmail.com' My desired output: '@gmail.com' My current output: . (it's just a period character) Here's my code: import re test_string = 'blahblah@gmail.com' domain = re.search('@*?\.', test_string) print domain.group() Here's what I think my regular expression says ('@*?.', test_string): ' # begin to define the pattern I'm looking for (also tell python this is a string) @ # find all patterns beginning with

How do I search through MATLAB command history?

百般思念 提交于 2019-12-18 14:05:51
问题 I would like to search for a specific command I've previously used. Is it possible to do a free text search on MATLAB command history? 回答1: If you want to accomplish this in a programmatic and platform-independent manner, you can first use MATLAB's Java internals to get the command history as a character array: history = com.mathworks.mlservices.MLCommandHistoryServices.getSessionHistory; historyText = char(history); Then you can search through the character array however you like, using

In less-than-linear time, find the duplicate in a sorted array

走远了吗. 提交于 2019-12-18 13:07:26
问题 Today, an interviewer asked me this question. My immediate response was that we could simply do a linear search, comparing the current element with the previous element in the array. He then asked me how the problem could be solved in less-than-linear time. Assumptions The array is sorted There is only one duplicate The array is only populated with numbers [0, n] , where n is the length of the array. Example array : [0,1,2,3,4,5,6,7,8,8,9] I attempted to come up with a divide-and-conquer

Search by date using command line

落爺英雄遲暮 提交于 2019-12-18 12:56:19
问题 Is there any way to search for files in a directory based on date? I want to find all files with created date greater than a specific date, is it possible to do it with dir command? 回答1: dir by itself can not filter by date, but you can parse the output of dir using for command. If in your country dir prints the date in YMD format, then you only need to compare it with given date. If the order of date parts is different, then you have to use another for command to parse the date and change it

HashMap<String, Integer> Search for part of an key? [duplicate]

不打扰是莪最后的温柔 提交于 2019-12-18 12:52:43
问题 This question already has answers here : Partial search in HashMap (5 answers) Closed 3 years ago . I am currently using HashMap<String, Integer> which is filled with keys of type String which are all, let's say, 5 chars long. How can I search for an specific key of 4 chars or less, which is part and at the beginning of some other keys and get all hits as a collection of <Key, Value> ? 回答1: Iterate is your only option unless you create a custom data structure: for (Entry<String, Integer> e :

Does F# documentation have a way to search for functions by their types?

夙愿已清 提交于 2019-12-18 12:52:28
问题 Say I want to know if F# has a library function of type ('T -> bool) -> 'T list -> int ie, something that counts how many items of a list that a function returns true for. (or returns the index of the first item that returns true) I used to use the big list at the MSR site for F# before the documentation on MSDN was ready. I could just search the page for the above text because the types were listed. But now the MSDN documentation only lists types on the individual pages--the module page is a

MySQL: Look for the same string in multiple columns

…衆ロ難τιáo~ 提交于 2019-12-18 12:47:15
问题 I am trying to make a search-page-like function. I want to make a query to look for "query" in "ColumnA" and "ColumnB" and "ColumnC" and "ColumnD". And select the rows which has the word/phrase "query" in any of those columns. This appears to work: SELECT * FROM projects WHERE category LIKE '%query%' OR name LIKE '%query%' OR description LIKE '%query%'OR keywords LIKE '%query%' OR 'type' LIKE '%query%' ORDER BY name ASC But it is lengthy. Is there any easier or more efficient way of doing

More efficient way to search an array of javascript objects?

倖福魔咒の 提交于 2019-12-18 12:42:52
问题 Not sure about posting rules, but I will tell you out of the gate that this is a repeat question of this one, but I am asking if this is the "best practice" way to do this? 回答1: That is the straight forward to do this. If you need fast access multiple times, you should create a map keyed by the property name that you're searching by. Here's a function that takes arrays and builds keyed maps. It's not all-purpose, but you should be able to modify it for your own use. /** * Given an array and a

What is the SQL used to do a search similar to “Related Questions” on Stackoverflow

自闭症网瘾萝莉.ら 提交于 2019-12-18 12:34:44
问题 I am trying to implement a feature similar to the "Related Questions" on Stackoverflow. How do I go about writing the SQL statement that will search the Title and Summary field of my database for similar questions? If my questions is: "What is the SQL used to do a search similar to "Related Questions" on Stackoverflow". Steps that I can think of are; Strip the quotation marks Split the sentence into an array of words and run a SQL search on each word. If I do it this way, I am guessing that I