substring

function replace substring returns incorrect answer

本秂侑毒 提交于 2020-07-16 04:24:21
问题 I have a program replacing a substring in a string. The idea is to find the string_to_be_replaced in original_string , then realloc the new_string and connect it to replace_by string. It works for some cases but in some cases like below, it return wrong answer: Input: abc def ghi //orginal string (a blank space) //string to be replaced 1234 //replace by Output: abc1234defT123ghi Expected output: abc1234def1234ghi When I debug it, I saw a wrong character has been filled in the new_string after

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 manipulate SREC file

给你一囗甜甜゛ 提交于 2020-07-10 04:35:07
问题 I have an S19 file looking something like below: S0030000FC S30D0003C0000F0000000000000020 S3FD00000000782EFF1FB58E00003D2B00003D2B00003D2B00003D2B00003D2B00003D S3ED000000F83D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D S31500000400FFFFFFFFFFFFFFFFFFFFFFFF7EF9FFFF7D S3FD0000041010B5DFF828000468012147F22C10C4F20300016047F22010C4F2030000 S70500008EB4B8 I want to separate the first two characters and also the next two characters, and so on... I want it to look like below (last two

how to manipulate SREC file

Deadly 提交于 2020-07-10 04:32:34
问题 I have an S19 file looking something like below: S0030000FC S30D0003C0000F0000000000000020 S3FD00000000782EFF1FB58E00003D2B00003D2B00003D2B00003D2B00003D2B00003D S3ED000000F83D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D S31500000400FFFFFFFFFFFFFFFFFFFFFFFF7EF9FFFF7D S3FD0000041010B5DFF828000468012147F22C10C4F20300016047F22010C4F2030000 S70500008EB4B8 I want to separate the first two characters and also the next two characters, and so on... I want it to look like below (last two

how to manipulate SREC file

假装没事ソ 提交于 2020-07-10 04:32:21
问题 I have an S19 file looking something like below: S0030000FC S30D0003C0000F0000000000000020 S3FD00000000782EFF1FB58E00003D2B00003D2B00003D2B00003D2B00003D2B00003D S3ED000000F83D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D2B00003D S31500000400FFFFFFFFFFFFFFFFFFFFFFFF7EF9FFFF7D S3FD0000041010B5DFF828000468012147F22C10C4F20300016047F22010C4F2030000 S70500008EB4B8 I want to separate the first two characters and also the next two characters, and so on... I want it to look like below (last two

Excel VBA auto filter with substring

不打扰是莪最后的温柔 提交于 2020-07-08 19:50:02
问题 There are multiple rows in my excel with D column as: TDM - 02 Bundle Rehoming 5 NE, TDM - 02 Bundle Rehoming 23 NE, IP - 02 Bundle Rehoming 7 NE etc. Please note that the number of NEs are different at most of the places. I want to search a substring to auto filter in Excel VBA: sht2.Select sht2.Activate If sht2.FilterMode Then sht2.ShowAllData End If sht2.Range("D1:D" & LastRow).AutoFilter Field:=4, Criteria1:=Array( _ CStr("HYBRID ATM and IP - 02 Bundle Rehoming" & Chr(42)), _ CStr("TDM -

Oracle select mutual sub string from different rows

[亡魂溺海] 提交于 2020-07-08 00:48:43
问题 I would like to return new table in ORACLE where all the rows that have same values in 'col' column group together and the 'description' column will contain only the mutual sub strings when the different characters will replaced by '...' How can I do that? May I get your help please? Example: col description 1 Today is a good day 1 Today is perfect day 2 Hello world 2 Hello I'm here 3 Hi Result: col description 1 Today is … 2 Hello… 3 Hi thanks! 回答1: In order to achieve what you want, first

Oracle select mutual sub string from different rows

那年仲夏 提交于 2020-07-08 00:48:29
问题 I would like to return new table in ORACLE where all the rows that have same values in 'col' column group together and the 'description' column will contain only the mutual sub strings when the different characters will replaced by '...' How can I do that? May I get your help please? Example: col description 1 Today is a good day 1 Today is perfect day 2 Hello world 2 Hello I'm here 3 Hi Result: col description 1 Today is … 2 Hello… 3 Hi thanks! 回答1: In order to achieve what you want, first

Cut an UTF8 text in PHP

匆匆过客 提交于 2020-07-06 12:29:08
问题 I get UTF8 text from a database, and I want to show only the first $len characters (finishing in a word). I've tried several options but the function still doesn't work because of special characters (á, é, í, ó, etc). Thanks for the help! function text_limit($text, $len, $end='...') { mb_internal_encoding('UTF-8'); if( (mb_strlen($text, 'UTF-8') > $len) ) { $text = mb_substr($text, 0, $len, 'UTF-8'); $text = mb_substr($text, 0, mb_strrpos($text," ", 'UTF-8'), 'UTF-8'); ... } } Edit to add an