substr

MongoDB : Remove last two characters from String

删除回忆录丶 提交于 2021-02-07 19:14:06
问题 How to remove the last two characters of String in MongoDB? I have tried below solution but it did not work. $substr: [ "$document.field", 0, { $strLenCP: "$document.field" } - 2 ] 回答1: You have to use $add or $subrtract to evaluate the length of a new string: db.collection.aggregate([ { $project: { newStr: { $substr: [ "$document.field", 0, { $add: [ { $strLenCP: "$document.field" }, -2 ] } ] } } } ]) MongoDB Playground 来源: https://stackoverflow.com/questions/56537076/mongodb-remove-last-two

perl --> printing characters in between the multiple metacharacters present in a single line

血红的双手。 提交于 2021-01-29 10:14:51
问题 I am trying a script to find out the characters between the metacharacter "|". I tried to get the position of the first and the succeeding "|" metacharacter and tried to print the string between those two positions. Below is the code I tried: File : | A| B| Count| D| E| Expected output : A B Count D E if($line =~ /\|/) { while ($line =~ m/\|/g) { my $start_pos = $-[0]; my $end_pos = $+[0]; my $hit_pos = "$start_pos - $end_pos"; my $char = substr($line, $start_pos, $end_pos); if($char =~/\w/){

Oracle - replace string by appearance

走远了吗. 提交于 2021-01-29 05:37:19
问题 I have an interesting issue here, if you could share your thoughts ... I changed data a bit, but structure is same create table TestReplace (Description varchar2(500), ParamValue1 number, ParamValue2 number, ParamValue3 number); insert into TestReplace (Description) values ('This sentence has no parameteres, and it should be shown like this'); insert into TestReplace (Description, ParamValue1) values ('This sentence has only one parametere, and it should be shown right here {param} with rest

How to split a CLOB object using , and : delimiter in Oracle into multiple records

被刻印的时光 ゝ 提交于 2020-06-16 19:10:27
问题 I have a CLOB object sample as shown below. I want to first split this by using delimiter "," and save it in a temporary table for later use. ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0

How to split a CLOB object using , and : delimiter in Oracle into multiple records

房东的猫 提交于 2020-06-16 19:08:34
问题 I have a CLOB object sample as shown below. I want to first split this by using delimiter "," and save it in a temporary table for later use. ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0

How to split a CLOB object using , and : delimiter in Oracle into multiple records

假如想象 提交于 2020-06-16 19:08:12
问题 I have a CLOB object sample as shown below. I want to first split this by using delimiter "," and save it in a temporary table for later use. ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0,ABCDEF:PmId12345RmLn1VlId0

JavaScript: Extract first letter of every string in array?

三世轮回 提交于 2020-06-13 09:29:52
问题 I'm quite new in coding, so might be an easy question for you all. What exactly should I do if I have this array and want to just show the first letter of every element of it? var friends = ["John", "Will", "Mike"]; I wanted to do it with substr method but I just want to know how to do it with a string. 回答1: Use Array.map() to iterate the array, take the 1st letter using destructuring, and return it: const friends = ["John", "Will", "Mike"]; const result = friends.map(([v])=> v); console.log