extract

Applescript use google chrome to extract text

倖福魔咒の 提交于 2019-12-11 04:27:53
问题 I'm extracting text from a page on safari, everything work fine, However I can't adapt this script to Google Chrome Here is the Safari code to getInputByClass2(theClass, num) tell application "Safari" set input to do JavaScript " document.getElementsByClassName('" & theClass & "')[" & num & "].innerHTML;" in document 1 end tell return input end getInputByClass2 Here is the Chrome code to getInputByClass2(theClass, num) tell application "Google Chrome" set input to do JavaScript " document

Javascript Extract Comments RegExp

大兔子大兔子 提交于 2019-12-11 03:56:28
问题 I have a Javascript file like that /** * My Comment Line1 * My Comment Line2 */ var a = 123; /** * My Comment Line3 * My Comment Line4 */ var b = 456; I am using node.js to read the file and want to extract comments in this file. I use this regexp /\/\*\*((?:\r|\n|.)*)\*\// However this extracts /** * My Comment Line1 * My Comment Line2 */ var a = 123; /** * My Comment Line3 * My Comment Line4 */ My program have a loop to extract matched block one by one. So I want a RegExp to extract First

ZipArchive - addFile won't work

冷暖自知 提交于 2019-12-11 03:47:03
问题 Situation I have a .zip file. In this .zip is a folder "dist/", in the folder "dist/" are 2 things: 1) another folder "lib/" 2) a jar-file I open the .zip and extract the dist/jar-file. A "new" folder will appear on my disk "dist" with the jar in it I open the jar-file with ZipArchive and edit this where needed. Edits are saved by addFromString() Now comes the crucial part I want to re-add the jar-file into the .zip I do this by doing $zip->addFile($newdir . 'dist/' . $corefile, 'dist/' .

How to extract directory (and sub directories) from jar resource?

百般思念 提交于 2019-12-11 03:38:54
问题 I've a dir (with sub dirs) template that is kept as a resource inside a jar file. During run time I need to extract it (template) to tmp dir change some content and finally publish it as a zipped artifact. My question is: how to extract this content easily? I was trying getResource() as well as getResourceAsStream().. 回答1: Following code works fine here: (Java7) String s = this.getClass().getResource("").getPath(); if (s.contains("jar!")) { // we have a jar file // format: file:/location..

How can I use named range in Excel with OleDB?

岁酱吖の 提交于 2019-12-11 02:18:58
问题 I'm trying to extract data from a specific named range in Excel with ASP .NET/C#. Here is an exemple of what I'm trying to extract. What I want is "B", "C", "D" by using the name "RANGE_NAMED". Is it possible to do this with OleDB ? Best regards, Alex. 回答1: You could try this code using(OleDbConnection c = new OleDbConnection(con)) { c.Open(); string selectString = "SELECT * FROM [RANGE_NAMED]"; using(OleDbCommand cmd1 = new OleDbCommand(selectString)) { cmd1.Connection = c; var result = cmd1

Extract words from files

亡梦爱人 提交于 2019-12-11 01:09:03
问题 This question was migrated from Ask Ubuntu because it can be answered on Stack Overflow. Migrated 8 years ago . How can I extract all the words from a file, every word on a single line? Example: test.txt This is my sample text Output: This is my sample text 回答1: The tr command can do this... tr [:blank:] '\n' < test.txt This asks the tr program to replace white space with a new line. The output is stdout, but it could be redirected to another file, result.txt: tr [:blank:] '\n' < test.txt >

Print text between two strings on the same line

亡梦爱人 提交于 2019-12-11 00:58:03
问题 I've been searching for a ling time, and have not been able to find a working answer for my problem. I have a line from an HTML file extracted with sed '162!d' skinlist.html , which contains the text <a href="/skin/dwarf-red-beard-734/" title="Dwarf Red Beard"> . I want to extract the text Dwarf Red Beard , but that text is modular (can be changed), so I would like to extract the text between title=" and " . I cannot, for the life of me, figure out how to do this. 回答1: awk 'NR==162 {print $4}

Extracting selected data from a text file in Ruby

橙三吉。 提交于 2019-12-11 00:38:19
问题 Now I am working on extracting information from a text file in Ruby. Then how can I extract just the number '0.6748984055823062' from the following text file? { "sentiment_analysis": [ { "positive": [ { "sentiment": "Popular", "topic": "games", "score": 0.6748984055823062, "original_text": "Popular games", "original_length": 13, "normalized_text": "Popular games", "normalized_length": 13, "offset": 0 }, { "sentiment": "engaging", "topic": "pop culture-inspired games", "score": 0

How to str_extract percentages in R?

让人想犯罪 __ 提交于 2019-12-10 23:20:00
问题 From this string border-color:#002449;left:74.4%top;37%; I would like to make the first percentage 74.4% a variable called X and the second percentage 37% a variable called Y . I have tried to play around with this regex "^.*?(\\d+)%.*" but this takes out the % sign and only extracts the second 4 from 74.4 Any help will be appreciated. Please let me know if any further information is needed. 回答1: s <- "border-color:#002449;left:74.4%top;37%;" regmatches(s, gregexpr("\\d+(\\.\\d+){0,1}%", s))[

Extract part of a string from a URL - Java Regex

拈花ヽ惹草 提交于 2019-12-10 21:47:08
问题 I'm trying to extract a string between '/' and '.' of a URL. For example, I have a URL like "some.com/part1/part2/part3/stringINeed.xyz". I need to extract "stringINeed" from the above URL, the one between last '/' and the '.' nothing else. So far, I tried the following and it gives an empty output: import java.util.*; import java.lang.*; import java.io.*; import java.util.regex.Pattern; import java.util.regex.Matcher; class Extract { public static void main (String[] args) throws java.lang