contains

Better way to detect if a string contains multiple words

霸气de小男生 提交于 2020-07-14 17:57:54
问题 I am trying to create a program that detects if multiple words are in a string as fast as possible, and if so, executes a behavior. Preferably, I would like it to detect the order of these words too but only if this can be done fast. So far, this is what I have done: if (input.contains("adsf") && input.contains("qwer")) { execute(); } As you can see, doing this for multiple words would become tiresome. Is this the only way or is there a better way of detecting multiple substrings? And is

Better way to detect if a string contains multiple words

无人久伴 提交于 2020-07-14 17:57:30
问题 I am trying to create a program that detects if multiple words are in a string as fast as possible, and if so, executes a behavior. Preferably, I would like it to detect the order of these words too but only if this can be done fast. So far, this is what I have done: if (input.contains("adsf") && input.contains("qwer")) { execute(); } As you can see, doing this for multiple words would become tiresome. Is this the only way or is there a better way of detecting multiple substrings? And is

How to delete all the files from folder where name does not include string listed in CSV using PowerShell

雨燕双飞 提交于 2020-06-27 04:09:57
问题 I want to delete all the files from folder where name does not include SKU listed in CSV. This works if SKU is exact match with the file base, but I also want keep images which include the SKU. For example if SKU is "1-526-2" files with names like "1-526-2_1.jpg" and "1-526-2_2.jpg" should not be deleted. Can you somehow add wildcards around the SKU? Trying to use this: $filestokeep = import-csv "C:\Users\exmaple\csv.csv" -Header sku).sku $files = "C:\users\folder" $data = Get-ChildItem

awk, if else conditional when record contains a value

依然范特西╮ 提交于 2020-06-16 17:27:11
问题 I'm having trouble getting an awk if/else conditional to properly trigger when the record contains a value. Running this in zsh on Mac OS Catalina. This script (issue is on second to last line)... echo "abcdefgh" > ./temp echo "abc\"\(\"h" >> ./temp echo "abcdefgh" >> ./temp echo "abcde\(h" >> ./temp val='"\("' key="NEW_NEW" file="./temp" echo $val echo $key echo $file echo "" echo "###############" echo "" awk ' BEGIN { old=ARGV[1]; new=ARGV[2]; ARGV[1]=ARGV[2]=""; len=length(old) } ($0 ~

awk, if else conditional when record contains a value

狂风中的少年 提交于 2020-06-16 17:25:28
问题 I'm having trouble getting an awk if/else conditional to properly trigger when the record contains a value. Running this in zsh on Mac OS Catalina. This script (issue is on second to last line)... echo "abcdefgh" > ./temp echo "abc\"\(\"h" >> ./temp echo "abcdefgh" >> ./temp echo "abcde\(h" >> ./temp val='"\("' key="NEW_NEW" file="./temp" echo $val echo $key echo $file echo "" echo "###############" echo "" awk ' BEGIN { old=ARGV[1]; new=ARGV[2]; ARGV[1]=ARGV[2]=""; len=length(old) } ($0 ~

Why is SQL Server full-text search not matching numbers?

偶尔善良 提交于 2020-06-12 06:03:23
问题 I'm using SQL Server 2014 Express, and have a full-text index setup on a table. The full-text index only indexes a single column, in this example named foo . The table has 3 rows in it. The values in the 3 rows, for that full-text indexed column are like so ... test 1 test 2 test 3 test 1 Each new line above is a new row in the table, and that text is literally what is in the full-text indexed column. So, using SQL Server's CONTAINS function, if I perform the following query, I get all rows

How to check if a List in a ViewBag contains string

折月煮酒 提交于 2020-05-28 08:09:18
问题 I have a ViewBag that is a list which i create in the controller: List<string> listoflists = new List<string>(); it then gets filled with some string like for example: listoflists.Add("java"); listoflists.Add("php"); listoflists.Add("C#"); Adding it to the ViewBag: ViewBag.listoflists = listoflists; i then would like to check in my View if this contains a specific string: @if(ViewBag.listoflists.contains("java") { // do html stuff } but when running this i get the following error: System

How to check if a List in a ViewBag contains string

醉酒当歌 提交于 2020-05-28 08:09:00
问题 I have a ViewBag that is a list which i create in the controller: List<string> listoflists = new List<string>(); it then gets filled with some string like for example: listoflists.Add("java"); listoflists.Add("php"); listoflists.Add("C#"); Adding it to the ViewBag: ViewBag.listoflists = listoflists; i then would like to check in my View if this contains a specific string: @if(ViewBag.listoflists.contains("java") { // do html stuff } but when running this i get the following error: System

Find any word of a list in the column of dataframe

青春壹個敷衍的年華 提交于 2020-03-23 08:03:06
问题 I have a list of words negative that has 4783 elements. I want to use the following code tweets3 = tweets2[tweets2['full_text'].str.contains('|'.join(negative))] But, it gives ane error like this error: multiple repeat at position 4193 . I do not understand this error. Apparently, if I use a single word in str.contains such as str.contains("deal") I am able to get results. All I need is a new dataframe that carries only those rows which carry any of the words occuring in the dataframe tweets2

How do I use LINQ Contains(string[]) instead of Contains(string)

我们两清 提交于 2020-02-08 18:08:13
问题 I got one big question. I got a linq query to put it simply looks like this: from xx in table where xx.uid.ToString().Contains(string[]) select xx The values of the string[] array would be numbers like (1,45,20,10,etc...) the Default for .Contains is .Contains(string) . I need it to do this instead: .Contains(string[]) ... EDIT : One user suggested writing an extension class for string[] . I would like to learn how, but any one willing to point me in the right direction? EDIT : The uid would