text-parsing

Powershell command to trim path if it ends with “\”

匆匆过客 提交于 2019-12-12 09:35:17
问题 I need to trim path if it ends with \ . C:\Ravi\ I need to change to C:\Ravi I have a case where path will not end with \ (Then it must skip). I tried with .EndsWith("\") , but it fails when I have \\ instead of \ . Can this be done in PowerShell without resorting to conditionals? 回答1: no need to overcomplicate "C:\Ravi\".trim('\') 回答2: Consider using TrimEnd instead (especially if you are working with UNC Path): "C:\Ravi\".TrimEnd('\') 回答3: You mention needing to differentiate between paths

Parsing / Extracting Text from String in Rails?

。_饼干妹妹 提交于 2019-12-12 09:14:35
问题 I have a string in Rails, e.g. "This is a Twitter message. #books War & Peace by Leo Tolstoy. I love this book!", and I want to parse the text and extract only certain phrases, like "War & Peace by Leo Tolstoy". Is this a matter of using Regex and lifting the text between "#books" to "."? What if there's no structure to the message, like: "This is a Twitter message #books War & Peace by Leo Tolstoy I love this book!" or "This is a Twitter message. I love the book War & Peace by Leo Tolstoy

Activate specific URL contained in an email message - Take 2

拜拜、爱过 提交于 2019-12-12 04:50:57
问题 First, thanks to all who have already assisted in the first iteration of this message. After looking around at other sites I found a better method for searching messages for URLs using regular expressions on this page, Open All Hyperlinks in an Outlook Email Message, on slipstick.com. The my personal tweaking of the code is: Option Explicit Public Sub OpenLinksMessage() Dim olMail As Outlook.MailItem Dim Reg1 As RegExp Dim AllMatches As MatchCollection Dim M As Match Dim strURL As String Dim

Updating a row in a data file with values from another row

元气小坏坏 提交于 2019-12-12 04:32:53
问题 I have some data in tab delimited form that gives the result of device identification from user-agents (UAs). but there are several rows where the devices are wrongly identified and I need to change them to the correct ones. For instance there are cases when and iphone or htc wildfire UA is identified as another phone. So for there cases I need to update the device information with the correct device by searching for certain keywords in the UA. for example, 781 Mozilla/5.0 (Linux; U; Android

Parsing text file in matlab

时间秒杀一切 提交于 2019-12-12 04:14:12
问题 I have this txt file: BLOCK_START_DATASET dlcdata L:\loads\confidential\000_Loads_Analysis_Environment\Tools\releases\01_Preprocessor\Version_3.0\Parameterfiles\Bladed4.2\DLC-Files\DLCDataFile.txt simulationdata L:\loads\confidential\000_Loads_Analysis_Environment\Tools\releases\01_Preprocessor\Version_3.0\Parameterfiles\Bladed4.2\DLC-Files\BladedFile.txt outputfolder Pfadangabe\runs_test windfolder L:\loads2\WEC\1002_50-2\_calc\50-2_D135_HH95_RB-AB66-0O_GL2005_towerdesign_Bladed_v4-2_revA01\

Parsing with MaltParser engmalt

五迷三道 提交于 2019-12-12 02:45:53
问题 I'm trying to use the pretrained parsing model engmalt. I downloaded it, I unpacked it in the directory where I downloaded the MaltParser, and I wrote in the prompt java -Xmx1024m -jar malt.jar -c engmalt.poly -i infile.conll -o outfile.conll -m parse as suggested in MalParser site. The problem is that it gives me this error: the file entry "engmaltpoly_single.info" in the mco file "../malt-1.4.1/engmaltpoly.mco" cannot be found. Can someone help me? I'm working with Windows7 and jre6. How

python extract words from xml

三世轮回 提交于 2019-12-12 01:53:15
问题 How to extract all words between <text></text> from big xml file (1.3 gb) whose structure is as follows: <mediawiki xmlns="http://www.mediawiki.org/xml/export-0.10/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd" version="0.10" xml:lang="pl"> <siteinfo> <sitename>Wikipedia</sitename> <dbname>plwiki</dbname> <base>http://pl.wikipedia.org/wiki/Wikipedia:Strona_g%C5%82%C3%B3wna<

Read fields from text file and store them in a structure

我怕爱的太早我们不能终老 提交于 2019-12-11 19:38:37
问题 I am trying to read a file that looks as follows: Data Sampling Rate: 256 Hz ************************* Channels in EDF Files: ********************** Channel 1: FP1-F7 Channel 2: F7-T7 Channel 3: T7-P7 Channel 4: P7-O1 File Name: chb01_02.edf File Start Time: 12:42:57 File End Time: 13:42:57 Number of Seizures in File: 0 File Name: chb01_03.edf File Start Time: 13:43:04 File End Time: 14:43:04 Number of Seizures in File: 1 Seizure Start Time: 2996 seconds Seizure End Time: 3036 seconds So far

C++: How to search for quoatations using stacks

坚强是说给别人听的谎言 提交于 2019-12-11 16:12:28
问题 I have to create a program that reads in a text file and checks for matching parenthesis, brackets, [] , quote symbols, and block comment. If there is an imbalance it returns false, if it is balanced it returns true. I have done [] () {} and need help making it work for /* */ , " " , and ' ' where everything inside the single/double quotes and the block comments are ignored. I've tried many things but have been unsuccessful in getting them to work. 回答1: The program now needs to handle two

I am very confused on how to parse multiple delimiters using getline and strtok in c++

守給你的承諾、 提交于 2019-12-11 13:11:35
问题 My code is posted below. I want to be able to parse using the delimiters " ()," and convert the strings into integers in cpp. while(getline(fin, line)) { x = atoi((strtok(line.c_str(),'(,)')); xx = atoi((strtok(NULL,"(),")); xxx = atoi((strtok(NULL,"(),"))); cout << x << " " << xx << " " << xxx << "\n"; } but for some reason I get the following errors GraphTest.cpp:134: error: invalid conversion from ‘const char*’ to ‘char*’ GraphTest.cpp:134: error: initializing argument 1 of ‘char* strtok