search

find in files using ruby or python

坚强是说给别人听的谎言 提交于 2019-12-19 09:06:31
问题 A popular text editor has the following "find in files" feature that opens in a dialog box: Look For: __searchtext__ File Filter: *.txt; *.htm Start From: c:/docs/2009 Report: [ ] Filenames [ ]FileCount only Method: [ ] Regex [ ]Plain Text In fact, several popular text editors have this. I would like to do the same thing but using a python or ruby class instead of a text editor. That way, this same kind of brain-dead simple operation can be run from a script on any platform that supports ruby

searching within nested list in python

孤人 提交于 2019-12-19 08:52:28
问题 I have a list: l = [['en', 60, 'command'],['sq', 34, 'komand']] I want to search for komand or sq and get l[1] returned. Can I somehow define my own matching function for list searches? 回答1: An expression like: next(subl for subl in l if 'sq' in subl) will give you exactly the sublist you're searching for (or raise StopIteration if there is no such sublist; if the latter behavior is not what you want, pass next a second argument [[e.g, [] or None , depending on what exactly you want!]] to

Find word in HTML page fast algorithm

拜拜、爱过 提交于 2019-12-19 08:17:31
问题 I need to do a boolean function which returns true if a word is in the text of a HTML page and false if it's not. I know that it's easy to do analysing all the page tree until finding the word with the lxml library but I find inefficient to iterate through all the html blocks and find if the word is there. Any suggestions for a faster algorithm (I need to do this search so many times)? 回答1: As long as you're not worried about accidentally finding the word in an element attribute or something

Find word in HTML page fast algorithm

浪子不回头ぞ 提交于 2019-12-19 08:17:12
问题 I need to do a boolean function which returns true if a word is in the text of a HTML page and false if it's not. I know that it's easy to do analysing all the page tree until finding the word with the lxml library but I find inefficient to iterate through all the html blocks and find if the word is there. Any suggestions for a faster algorithm (I need to do this search so many times)? 回答1: As long as you're not worried about accidentally finding the word in an element attribute or something

Sending multiple checkbox options

丶灬走出姿态 提交于 2019-12-19 08:12:36
问题 I'm creating a used cars website (written in PHP), and I'm stuck on sending advanced search options from form. I have more than 30 of them and I wonder if it's possible, and how, to send them in one variable (for example &options=1,2,3,5,6,10 or some other way..). Also I've heard that this is possible with "bitwise" but I don't have a clue how to do that. Or if someone have a better idea, please let me know. Thanks. 回答1: You can send them in an array. <form method="post"> <input type=

How to use Windows Search Service in c#

♀尐吖头ヾ 提交于 2019-12-19 08:12:31
问题 I'm working on an application, an user can search for files or folders either on the local computer or on the network. I am using DirectoryInfo.GetDirecotories(). (a) But I also want to add the functionality that windows 7 uses for searching, I believe that uses indexing. I also saw "Windows Searching Service" on msdn, but I'm not sure which way is best, querying the indexed catalog or using the search service, any suggestions ? (b) I was wondering if any one can give me a small example in C#

Sending multiple checkbox options

纵然是瞬间 提交于 2019-12-19 08:10:13
问题 I'm creating a used cars website (written in PHP), and I'm stuck on sending advanced search options from form. I have more than 30 of them and I wonder if it's possible, and how, to send them in one variable (for example &options=1,2,3,5,6,10 or some other way..). Also I've heard that this is possible with "bitwise" but I don't have a clue how to do that. Or if someone have a better idea, please let me know. Thanks. 回答1: You can send them in an array. <form method="post"> <input type=

MariaDB regex working in online regex testers does not work in SELECT WHERE REGEXP

跟風遠走 提交于 2019-12-19 08:06:42
问题 I'm having a problem a dataset I have been given in bad format E.G fullName column and no breakdown of names I'm wanting to search where any of the names start with a given letter E.G 'J' So this is my Statement but I just get complaints about unexpected REGEXP SELECT * FROM `Officers` WHERE `fullName` REGEXP '.*\sJ.*'; Is there any way to do this in MariaDB, unfortunately, the names are not of a fixed word count some are only 2 names others are 6 names long so 4 middle names. 回答1: You may

facet dynamic fields with apache solr

僤鯓⒐⒋嵵緔 提交于 2019-12-19 06:18:23
问题 I have defined dynamic field in ApacheSolr: I use it to store products features like: color_feature, diameter_feature, material_feature and so on. Number of those fields are not constant becouse products are changing. Is it possible to get facet result for all those dynamic fields with the same query or do I need to write always all fields in a query like ... facet.field=color_feature&facet.field=diameter_feature&facet.field=material_feature&facet.field= ... 回答1: Solr currently does not

Ignore case when trying to match file names using find command in Linux

孤者浪人 提交于 2019-12-19 05:22:17
问题 Right now, all I know to use is: find / -name string.* that is case sensitive and it won't find files named: 1string.x STRing.x string1.x How can I search so that all the above would be returned in the search to a case-insensitive matching? 回答1: Or you could use find / | grep -i string 回答2: Use the -iname option instead of -name . 回答3: This works as well, if you want to avoid the single quotes: find . -iname \*string\* 回答4: Use -iname in find for case insensitive file name matches. 回答5: If