extract

how to extract only the year from the date in sql server 2008?

与世无争的帅哥 提交于 2019-12-18 03:51:27
问题 In sql server 2008, how to extract only the year from the date. In DB I have a column for date, from that I need to extract the year. Is there any function for that? 回答1: year(@date) year(getdate()) year('20120101') update table set column = year(date_column) whre .... or if you need it in another table update t set column = year(t1.date_column) from table_source t1 join table_target t on (join condition) where .... 回答2: select year(current_timestamp) SQLFiddle demo 回答3: You can use year()

Save Icon File To Hard Drive

会有一股神秘感。 提交于 2019-12-18 03:35:11
问题 I know that this must be incredibly easy - It's unbelievable how long I have searched for an answer to this question based on how simple it is in VB6. I simply want to extract an Icon from an EXE File using Icon.ExtractAssociatedIcon, and then save this icon file to my hard drive. So, here is what I have, and I will also show you what I have tried so you don't think I'm being lazy. OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); string s = Environment.GetFolderPath(Environment

Extract part of URL

陌路散爱 提交于 2019-12-17 20:42:41
问题 I have an URL and need to extract a part of it. The url is like this: http://website.com/get.php?url=http://www.website2.com/index.html?articleID=123456 And I need to extract this part: http://www.website2.com/index.html?articleID=123456 How would I do this in Objective-C? 回答1: First of all, create a NSURL. Then, use the query method to get the query string part: NSURL * url = [ NSURL URLWithString: @"... your url ..." ]; NSString * q = [ url query ]; Then you can use the NSString methods to

Extract string within parentheses - PYTHON

梦想与她 提交于 2019-12-17 19:59:55
问题 I have a string "Name(something)" and I am trying to extract the portion of the string within the parentheses! Iv'e tried the following solutions but don't seem to be getting the results I'm looking for. n.split('()') name, something = n.split('()') 回答1: You can use a simple regex to catch everything between the parenthesis: >>> import re >>> s = 'Name(something)' >>> re.search('\(([^)]+)', s).group(1) 'something' The regex matches the first "(", then it matches everything that's not a ")": \

Javascript extracting number from string

戏子无情 提交于 2019-12-17 19:52:09
问题 I have a bunch of strings extracted from html using jQuery. They look like this: var productBeforePrice = "DKK 399,95"; var productCurrentPrice = "DKK 299,95"; I need to extract the number values in order to calculate the price difference. (So I wend up with ≈ var productPriceDiff = DKK 100"; or just: var productPriceDiff = 100"; ) Can anyone help me do this? Thanks, Jakob 回答1: First you need to convert the input prices from strings to numbers. Then subtract. And you'll have to convert the

How to extract a single file from a remote archive file?

混江龙づ霸主 提交于 2019-12-17 18:41:37
问题 Given URL of an archive (e.g. a zip file) Full name (including path) of a file inside that archive I'm looking for a way (preferably in Java) to create a local copy of that file, without downloading the entire archive first . From my (limited) understanding it should be possible, though I have no idea how to do that. I've been using TrueZip, since it seems to support a large variety of archive types, but I have doubts about its ability to work in such a way. Does anyone have any experience

Accessing last x characters of a string in Bash

自古美人都是妖i 提交于 2019-12-17 17:25:31
问题 I found out that with ${string:0:3} one can access the first 3 characters of a string. Is there a equivalently easy method to access the last three characters? 回答1: Last three characters of string : ${string: -3} or ${string:(-3)} (mind the space between : and -3 in the first form). Please refer to the Shell Parameter Expansion in the reference manual: ${parameter:offset} ${parameter:offset:length} Expands to up to length characters of parameter starting at the character specified by offset.

regex php: find everything in div

好久不见. 提交于 2019-12-17 16:51:08
问题 I'm trying to find eveything inside a div using regexp. I'm aware that there probably is a smarter way to do this - but I've chosen regexp. so currently my regexp pattern looks like this: $gallery_pattern = '/<div class="gallery">([\s\S]*)<\/div>/'; And it does the trick - somewhat. The problem is if i have two divs after each other - like this. <div class="gallery">text to extract here</div> <div class="gallery">text to extract from here as well</div> I want to extract the information from

VBScript to read specific line and extract characters and store it as a variable

僤鯓⒐⒋嵵緔 提交于 2019-12-17 16:41:35
问题 I have a VB script that reads the 11th line from a text file. However from that line I need to extract characters 48 through 53 and save it as a variable. After this is accomplished I would like to use that variable and use it in a web url. Example below: Contents of the szCPUSer.dat file look like this: The script I have reads the 10th line Const ForReading = 1 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile("szCPUSer.dat", ForReading) For i = 1

Java library for keywords extraction from input text

拜拜、爱过 提交于 2019-12-17 15:27:45
问题 I'm looking for a Java library to extract keywords from a block of text. The process should be as follows: stop word cleaning -> stemming -> searching for keywords based on English linguistics statistical information - meaning if a word appears more times in the text than in the English language in terms of probability than it's a keyword candidate. Is there a library that performs this task? 回答1: Here is a possible solution using Apache Lucene. I didn't use the last version but the 3.6.2 one