letters

OrderBy with Swedish letters

旧城冷巷雨未停 提交于 2019-12-04 01:33:15
I have a list of my custom class Customer and I want to sort them alphabetically by Title. So I wrote myList = myList.OrderByDescending(x => x.Title).ToList<Customer>(); Now the problem is that this method doesn't support the Swedish way of sorting the letters å, ä, ö. They should appear at the end after the letter z but they don't. So I made a workaround method that replaces the Swedish letters before the ordering and then changes them back afterwords. It looks like this but it is quite slow. Can somebody think of a better way? private List<Customer> OrderBySwedish(List<Customer> myList) {

Bash script to find the frequency of every letter in a file

断了今生、忘了曾经 提交于 2019-12-03 15:03:09
问题 I am trying to find out the frequency of appearance of every letter in the english alphabet in an input file. How can I do this in a bash script? 回答1: Just one awk command awk -vFS="" '{for(i=1;i<=NF;i++)w[$i]++}END{for(i in w) print i,w[i]}' file if you want case insensitive, add tolower() awk -vFS="" '{for(i=1;i<=NF;i++)w[tolower($i)]++}END{for(i in w) print i,w[i]}' file and if you want only characters, awk -vFS="" '{for(i=1;i<=NF;i++){ if($i~/[a-zA-Z]/) { w[tolower($i)]++} } }END{for(i in

Sample SoftKeyboard double letters

匿名 (未验证) 提交于 2019-12-03 08:57:35
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm android's beginner developer , I downloaded source code for sample SoftKeyboard https://android.googlesource.com/platform/development/+/android-2.3.3_r1.1/samples/SoftKeyboard First i had problem which is "When Typing a letter/letters , and switching to Symbol Keyboard , and type a number , the previous letter/letters Typed is Removed" i fixed it by removing else from method handleCharacter() in SoftKeyboard.java private void handleCharacter(int primaryCode, int[] keyCodes) { if (isInputViewShown()) { if (mInputView.isShifted()) {

Change every other letters font color? (JavaScript)

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create a Christmas user group on my forums, and would like to replace the users name with a green/red pattern using JavaScript. So basically, JavaScript would turn every other letter within a specific CSS class into green, and the others would stay red. So this is what it looks like now: <span class="style6">Username</span> I'd like JavaScript to turn it into something like this: <span class="style6"> <span class="color_red">U</span> <span class="color_green">s</span> <span class="color_red">e</span> <span class="color_green">r

Bash script to find the frequency of every letter in a file

て烟熏妆下的殇ゞ 提交于 2019-12-03 04:45:26
I am trying to find out the frequency of appearance of every letter in the english alphabet in an input file. How can I do this in a bash script? Just one awk command awk -vFS="" '{for(i=1;i<=NF;i++)w[$i]++}END{for(i in w) print i,w[i]}' file if you want case insensitive, add tolower() awk -vFS="" '{for(i=1;i<=NF;i++)w[tolower($i)]++}END{for(i in w) print i,w[i]}' file and if you want only characters, awk -vFS="" '{for(i=1;i<=NF;i++){ if($i~/[a-zA-Z]/) { w[tolower($i)]++} } }END{for(i in w) print i,w[i]}' file and if you want only digits, change /[a-zA-Z]/ to /[0-9]/ if you do not want to show

UK Postcode Regex [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This question already has an answer here: UK Postcode Regex (Comprehensive) 28 answers I'm looking to be able to validate UK Postcodes, and ideally, I would like the following cases to pass: W1 W12 WC1 WC1A WC12 W1 6BT W12 6BT WC1 6BT WC1A 6BT WC12 6BT W16BT W126BT WC16BT WC1A6BT WC126BT I have the following regex patterns: ^(GIR 0AA)|(((A[BL]|B[ABDHLNRSTX]?|C[ABFHMORTVW]|D[ADEGHLNTY]|E[HNX]?|F[KY]|G[LUY]?|H[ADGPRSUX]|I[GMPV]|JE|K[ATWY]|L[ADELNSU]?|M[EKL]?|N[EGNPRW]?|O[LX]|P[AEHLOR]|R[GHM]|S[AEGKLMNOPRSTY]?|T[ADFNQRSW]|UB|W[ADFNRSV]|YO|ZE)[1

Filter by multiple patterns with filter() and str_detect()

匿名 (未验证) 提交于 2019-12-03 01:36:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I would like to filter a dataframe using filter() and str_detect() matching for multiple patterns without multiple str_detect() function calls. In the example below I would like to filter the dataframe df to show only rows containing the letters a f and o . df <- data . frame ( numbers = 1 : 52 , letters = letters ) df %>% filter ( str_detect (. $letters , "a" )| str_detect (. $letters , "f" )| str_detect (. $letters , "o" ) ) # numbers letters #1 1 a #2 6 f #3 15 o #4 27 a #5 32 f #6 41 o I have attempted the following df %>%

Pandas: Randomize letters in a column

匿名 (未验证) 提交于 2019-12-03 01:00:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a data frame that looks like this: id1 | id2 ---------------------------- ab51c-ee-1a | cga--=%abd21 I am looking to randomize the letters only: id1 | id2 ---------------------------- ge51r-eq-1b | olp--=%cqw21 I think I can do something like this: newid1 = [] for index, row in df.iterrows(): string = '' for i in row['id1']: if i.isalpha(): string+=random.choice(string.letters) else: string+=i newcolumn.append(string) But it doesn't seem very efficient. Is there a better way? 回答1: Lets use apply , with the power of str.replace to

Python操作三大主流数据库

匿名 (未验证) 提交于 2019-12-02 22:11:45
var 课程地址 = " http://icourse8.com/Python_database.html "; const 地址 = " http://icourse8.com/Python_database.html "; 第1章 数据库简介 第2章 mysql基础 第3章 python API 第4章 ORM 第5章 网易新闻实战 第6章 MongoDB 数据库基础 第7章 Python操作MongoDB 第8章 MongoDB ODM(1) 第9章 MongoDB ODM(2) 第10章 MongoDB 网易新闻实战 第11章 Redis数据库基础 第12章 python操作redis 第13章 python操作resis网易新闻实战 class Solution { public String reverseVowels(String s) { char[] letters = s.toCharArray(); //使用快排的方法 List<Character> list = new ArrayList<>(); char[] letter=new char[] {'a','e','i','o','u','A','E','I','O','U'}; int len = s.length(); for(int i=0;i<len;i++) list.add(letter[i]

C#7.0特性

匿名 (未验证) 提交于 2019-12-02 22:06:11
一.out的形参变量无需再提前声明 befor: string input = "3"; int numericResult; if (int.TryParse(input, out numericResult)) Console.WriteLine(numericResult); else Console.WriteLine("Could not parse input"); after: string input = "3"; if (int.TryParse(input, out var numericResult)) Console.WriteLine(numericResult); else Console.WriteLine("Could not parse input"); 二.扩展了元组(Tuple的使用,需要Nuget引用 System.ValueTuple) 1.命名的改进: ①.无命名,仅能通过无意义的Item1,Item2进行访问: var letters = ("a", "b"); Console.WriteLine($"Value is {letters.Item1} and {letters.Item2>}"); befor: (string first, string second) letters = ("a", "b"); Console