trim

How to trim string using predefined special characters in SQL Server?

妖精的绣舞 提交于 2019-12-07 10:27:28
问题 I want to trim SQL Server strings using some special characters such as "،,.?!؛,،,><=+ـ". The SQL server ltrim and rtrim functions only strips the space characters. DECLARE @Str NVARCHAR(100) = N',,,,,!؛Computation+Time, Cost،,.?!؛,،,><=+ـ' SELECT dbo.SpecialTrim(@Str, N'،,.?!؛,،,><=+ـ') The result : Computation+Time, Cost Have anyone any ideas in order to implement SpecialTrim function? 回答1: The below hardcodes the pattern. It looks for the first character that is not one of the characters

Trim field value, or remove part of the value

笑着哭i 提交于 2019-12-07 05:09:34
问题 I am trying to adjust path name so that it no longer has the time stamp attached to the end. I am input many different logs so it would be impractical to write a conditional filter for every possible log. If possible I would just like to trim the last nine characters of the value. For example "random.log-20140827" would become "random.log" . 回答1: So if you know it's always going to be random.log-something -- if [path] =~ /random.log/ { mutate { replace => ["path", "random.log"] } } If you

How to sort in SQL, ignoring articles ('the“, ”a', “an” etc)

孤街醉人 提交于 2019-12-06 23:51:30
问题 This comes up a lot, and I can see it's come up on StackOverflow for XSLT, Ruby and Drupal but I don't see it specifically for SQL. So the question is, how do you sort titles correctly when they begin with "The", "A", or "An"? One way is simply to TRIM() those strings: ORDER BY TRIM( LEADING 'a ' FROM TRIM( LEADING 'an ' FROM TRIM( LEADING 'the ' FROM LOWER( title ) ) ) ) which was suggested on AskMeFi a while back (does it need that LOWER() function?). I know I've also seen some kind of Case

Split string data on a string match

安稳与你 提交于 2019-12-06 20:37:28
I'm working with some xml and I'd like to clean it up before I parse it. What i'd like to do specifically, is take the data (example below) and match it on the string " <data> " and then trim everything before it leaving the node in tact. Then I would match on the string " </data> " and truncate everything after it, once again leaving the matched node in tact. Turning this: <dwml> <head> <child></child> </head> <data> <child></child> <child></child> </data> <more></more> </dwml> into this: <data> <child></child> <child></child> </data> My Question: While I am sure there is a way to do this, I

oracle trim函数去空格

依然范特西╮ 提交于 2019-12-06 16:41:37
TRIM Syntax Description of the illustration trim.gif Purpose TRIM enables you to trim leading or trailing characters (or both) from a character string. If trim_character or trim_source is a character literal, then you must enclose it in single quotes. If you specify LEADING , then Oracle Database removes any leading characters equal to trim_character . If you specify TRAILING , then Oracle removes any trailing characters equal to trim_character . If you specify BOTH or none of the three, then Oracle removes leading and trailing characters equal to trim_character . If you do not specify trim

Trim function does not remove spaces at end of a string while comparing two strings in vbs

陌路散爱 提交于 2019-12-06 13:33:40
I have a simple script which takes two strings and compare them. The first one has a space at the end and the second does not have that. Function compare(str1,str2) dim a If strComp(trim(str1),trim(str2))=0 Then msgbox "OK" a=1 Else msgbox "KO" a=0 End If compare=a End Function I use this function in this way: s1= SUCCESSFULLY CONNECTED s2= SUCCESSFULLY CONNECTED result=compare(s1,s2) The difference between s1 and s2 is that s1 ends with a single space while s2 does not have any space at the end. This why I use the Trim function to ignore that space. Despite that, for s1 and s2, I always get

SQL Server : how to split a string using a comma as a separator [duplicate]

余生长醉 提交于 2019-12-06 11:45:43
问题 This question already has answers here : Split function equivalent in T-SQL? (15 answers) Closed 6 years ago . I need to populate columns in my database for Latitude and Longitude, however the original information is stored as a single string eg. UDFChar1 = 41.243223,-8.183913 I am guessing that the TRIM command will come in useful here, but I do not know how I can tell it to stop exactly on the comma for each half. What I'm hoping to be able to come up with is a simple UPDATE query as per

jquery trim leading zeros from date of format 01/02/2010

你说的曾经没有我的故事 提交于 2019-12-06 05:42:48
How do I trim javascript date object returned as 01/26/2012 into 1/26/2012? it could be applicable for both month or days. So 01/01/2012 should be trimmed as 1/1/2012. Regular expression? jquery trim function? I am not sure how to go on this? var date=date.replace(/^0+/, ''); or var trimmed = s.replace(/\b(0(?!\b))+/g, "") For a simple string operation, a RegEx can be used: date = date.replace(/\b0(?=\d)/g, '') Jason McCreary If it is indeed a date object format it . Quick example (See it in action ): var today = new Date(); var today_string = (today.getMonth() + 1) + '/' + today.getDate() + '

Trim only the first and last occurrence of a character in a string (PHP)

北战南征 提交于 2019-12-06 05:17:29
This is something I could hack together, but I wondered if anybody had a clean solution to my problem. Something that I throw together wont necessarily be very concise or speedy! I have a string like this ///hello/world/// . I need to strip only the first and last slash, none of the others, so that I get a string like this //hello/world// . PHP's trim isn't quite right right: performing trim($string, '/') will return hello/world . One thing to note is that the string won't necessarily have any slashes at the beginning or end. Here are a few examples of what I would like to happen to different

php, count characters and deleted what is more than 140 characters

橙三吉。 提交于 2019-12-06 05:14:52
I need a PHP function that will count the number of characters of a phrase. If the phrase is longer than "140" character then this function should delete all the other character and add three points at then end of the phrase. So for example we have. $message= "I am what I am and you are what you are etc etc etc etc" IF this is longer than 140 characters, then $message= "I am what I am and you are what you are..." Is this possible? How? Thank you if(strlen($str) > 140){ $str = substr($str, 0, 140).'...'; } If you want to be "word sensitive" (i.e. not break in the middle of the word), you can