substring

Is there a way to find out how many numbers are at the end of a string without knowing the exact index?

匆匆过客 提交于 2021-01-05 07:09:15
问题 I have a method that extracts a certain substring from a string. This substring consists of the numbers in the string. Then this is parsed to an integer. Method: protected int startIndex() throws Exception { String str = getWorkBook().getDefinedName("XYZ"); String sStr = str.substring(10,13); return Integer.parseInt(sStr) - 1; } Example: String : '0 DB'!$B$460 subString : 460 Well, I manually entered the index range for the substring. But I would like to automate it. My approach: String str =

Check if its a perfect string [closed]

為{幸葍}努か 提交于 2020-12-27 05:31:30
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 hours ago . Improve this question I'm learning to solve algorithms A string comprlsed of digits from 0 to 9 contains a perfect substring If all the elements within a substring occur exactly k times. Calculate the number of perfect substring in s. Example Example s = 1102021222 k = 2 The 6 perfect substrings are:

Check if its a perfect string [closed]

时光毁灭记忆、已成空白 提交于 2020-12-27 05:31:19
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 hours ago . Improve this question I'm learning to solve algorithms A string comprlsed of digits from 0 to 9 contains a perfect substring If all the elements within a substring occur exactly k times. Calculate the number of perfect substring in s. Example Example s = 1102021222 k = 2 The 6 perfect substrings are:

Check if its a perfect string [closed]

纵饮孤独 提交于 2020-12-27 05:28:52
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 10 hours ago . Improve this question I'm learning to solve algorithms A string comprlsed of digits from 0 to 9 contains a perfect substring If all the elements within a substring occur exactly k times. Calculate the number of perfect substring in s. Example Example s = 1102021222 k = 2 The 6 perfect substrings are:

Using compareToIgnoreCase() to compare an entry to substring in string without using array

夙愿已清 提交于 2020-12-26 12:24:57
问题 In my assignment it's forbidden to use collections and any arrays. We are allowed to use String Tokenizer but any other classes than String and System are not allowed. This solution has to work with any number of entries. I have a string which look like this : 1|Aaron|Peter|3063543030|john@gmail.com + "\n" 2|Buffet|Anthony|3063543030|john@gmail.com + "\n" 3|Dunty|Richard|3063543030|john@gmail.com For example, if the entry is 4|Doe|John|3063543030|john@gmail.com then the comparison will be

Using compareToIgnoreCase() to compare an entry to substring in string without using array

折月煮酒 提交于 2020-12-26 12:24:06
问题 In my assignment it's forbidden to use collections and any arrays. We are allowed to use String Tokenizer but any other classes than String and System are not allowed. This solution has to work with any number of entries. I have a string which look like this : 1|Aaron|Peter|3063543030|john@gmail.com + "\n" 2|Buffet|Anthony|3063543030|john@gmail.com + "\n" 3|Dunty|Richard|3063543030|john@gmail.com For example, if the entry is 4|Doe|John|3063543030|john@gmail.com then the comparison will be

Sorting strings by a substring in Python [duplicate]

…衆ロ難τιáo~ 提交于 2020-11-27 01:57:47
问题 This question already has answers here : python, sorting a list by a key that's a substring of each element (5 answers) Closed 15 days ago . I have a list of strings in python that looks like this: Name number number 4-digit number How can I sort it by the last number? 回答1: Like that: sorted(your_list, lambda x: int(x.split()[-1])) 回答2: my_list = ['abc 12 34 3333', 'def 21 43 2222', 'fgh 21 43 1111'] my_list.sort(key=lambda x:int(x.split()[-1])) my_list is now: ['fgh 21 43 1111', 'def 21 43

Sorting strings by a substring in Python [duplicate]

孤街浪徒 提交于 2020-11-27 01:57:16
问题 This question already has answers here : python, sorting a list by a key that's a substring of each element (5 answers) Closed 15 days ago . I have a list of strings in python that looks like this: Name number number 4-digit number How can I sort it by the last number? 回答1: Like that: sorted(your_list, lambda x: int(x.split()[-1])) 回答2: my_list = ['abc 12 34 3333', 'def 21 43 2222', 'fgh 21 43 1111'] my_list.sort(key=lambda x:int(x.split()[-1])) my_list is now: ['fgh 21 43 1111', 'def 21 43