contains

Sql Server 2008 Full-Text Index (characters issue)

那年仲夏 提交于 2019-12-13 01:17:20
问题 The Full-Text Index searching is working perfect but suddenly I noticed that it fails when it comes to some characters variance in Arabic In Arabic we have a trailing letter say {I} that can be written like { i } or { I } , It's the same letter but different ASCII code.. exactly like the English variance between { i } & { I } the "Contains" function can get "ALi" but not "ALI" both {ALi & ALI} exist.. {ALi} returns result but without the result of {ALI} {ALI} return 0 records when using full

pandas: How to limit the results of str.contains?

一笑奈何 提交于 2019-12-12 12:48:55
问题 I have a DataFrame with >1M rows. I'd like to select all the rows where a certain column contains a certain substring: matching = df['col2'].str.contains('substr', case=True, regex=False) rows = df[matching].col1.drop_duplicates() But this selection is slow and I'd like to speed it up. Let's say I only need the first n results. Is there a way to stop matching after getting n results? I've tried: matching = df['col2'].str.contains('substr', case=True, regex=False).head(n) and: matching = df[

Hide div if URL contains word

拜拜、爱过 提交于 2019-12-12 10:48:30
问题 I need to hide a div if the url of the page contains a certain word. Thanks to this site I have been able to successfully find if the url contains the word. This code works: <script type="text/javascript"> if (window.location.href.indexOf("Bar-Ends") != -1) { alert("your url contains bar ends"); } </script> but for some reason it will not work to hide a div, like this: <script type="text/javascript"> if (window.location.href.indexOf("Bar-Ends") != -1) { $("#notBarEnds").hide(); } </script>

MYSQL extract json elements where the json contains

旧巷老猫 提交于 2019-12-12 10:24:58
问题 I'v got table orders with orders . items as JSON example of orders . items cell: { "10": { "name": "item 1", "step": "1", "price": "140", "amount": "4", "category": "9" }, "24": { "name": "item 2", "step": "1", "price": "6.2", "amount": "1", "category": "5" }, "35": { "name": "item 3", "step": "1", "price": "2.9", "amount": "3", "category": "1" }, "37": { "name": "item 4", "step": "1", "price": "3.9", "amount": "2", "category": "9" } } i want to extract only items that in specific category

Python List Class __contains__ Method Functionality

点点圈 提交于 2019-12-12 08:28:19
问题 Does the __contains__ method of a list class check whether an object itself is an element of a list, or does it check whether the list contains an element equivalent to the given parameter? Could you give me an example to demonstrate? 回答1: >>> a = [[]] >>> b = [] >>> b in a True >>> b is a[0] False This proves that it is a value check (by default at least), not an identity check. Keep in mind though that a class can if desired override __contains__() to make it an identity check. But again,

Count appearances of a string throughout columns in pandas

冷暖自知 提交于 2019-12-12 05:57:27
问题 Consider the following dataframe: import pandas as pd df = pd.DataFrame(["What is the answer", "the answer isn't here, but the answer is 42" , "dogs are nice", "How are you"], columns=['words']) df words 0 What is the answer 1 the answer isn't here, but the answer is 42 2 dogs are nice 3 How are you I want to count the number of appearances of a certain string, that may repeat a few times in each index. For example, I want to count the number of times the answer appears. I tried: df.words.str

jQuery Extract Year from Date and Add Class to Parent

落爺英雄遲暮 提交于 2019-12-12 05:13:56
问题 I'm looking to create an isotope filter to a div list and as such want to add a class of the year to a parent container/div by extracting the 'Year' from a displayed date and then adding that as the class to the parent div ( .publication ) Right now I am using a very basic method to do this by looking to see if a div contains a specific year and then individually assigning a year: HTML <div> <div class="publication addyearclasshere"> <div class="publication-date">15/3/2017</div> </div> <div

Counting appearances of multiple substrings in a cell pandas

六眼飞鱼酱① 提交于 2019-12-12 04:56:57
问题 I have a column that contains rather lengthy strings. Each of the string may or may not contain substrics. Such substrings as 'H 07', 'H 06' or 'F 13' may or may not appear in a dataframe cell. I would like to count appearances of these substrings and add results to a new cell. The original cell value is df.iloc[0,0] 'rfgergerggr H 07 jgjg gjgj H 06 gjhgj H 06 '. The result of the procedure should be a new cell with df.iloc[0,1] {'H 07':1, 'H 06':2} I imagine that this should be done with

Select all anchor tags with an href attribute that contains one of multiple values via xpath in lxml / Python

别说谁变了你拦得住时间么 提交于 2019-12-12 02:48:55
问题 I need to automatically scan lots of html documents for ad banners that are surrounded by an anchor tag, e.g.: <a href="http://ad_network.com/abc.html"> <img src="ad_banner.jpg"> </a> As a newbie with xpath, I can select such anchors via lxml like so: text = ''' <a href="http://ad_network.com/abc.html"> <img src="ad_banner.jpg"> </a>''' root = lxml.html.fromstring(text) print root.xpath('//a[contains(@href,("ad_network.")) or contains(@href,("other_ad_network."))][descendant::img]') In the

can not make xpath with functions work with JDOM2

情到浓时终转凉″ 提交于 2019-12-12 01:42:37
问题 I used JDOM1 before to parse xmls with xpath, and tired with the non-generic style, so I decide to try JDOM2, OK, everything works perfect for me ( the generic, XPathFactory, XPathExpression). then I try a xpath statement with contains function : XPathExpression<Text> timeXpath = XPathFactory.instance().compile( "./p[contains(.,'time:')]/text()", Filters.textOnly()); String time = timeXpath.evaluateFirst(div).getTextTrim(); then I got exeptions: java.lang.IllegalStateException: Unable to