How to search for a string in a file and compare?

That is my first post on stackoverflow. Btw I am really noob. I would like to search a string with a comand like that: ./a.out foobar. I have a file, called list.txt, in which I have a list of names, I want to search in that file to find foobar. Wh...
more »

2017-12-02 23:12 (0) Answers

Python fstring as function

I'd like to use Python f-string for its syntactical simplicity, compared to string.Template() or other approach. However, in my application, the string is loaded from file, and the values of the variable can only be provided later. If there a way to...
more »

2017-12-01 17:12 (3) Answers

How to add two columns in MATLAB?

I am trying to create a simple text file from a MATLAB script that is ordered in the following matter that illustrates a classroom's grade throughout the semester. There are 20 entries for the 20 students enrolled, with 5 homework entries, a midterm ...
more »

2017-12-01 05:12 (3) Answers

Extract int value and string from string

I would like to use string class, to extract some information from the string. Given the string: <12,Apple>,<20,Orange>,<49,iPhone> I would like to let 12, 20, 49 to a int array. that means a[0] = 12, a[1] = 20, a[2] = 49. And let Apple, O...
more »

2017-11-30 04:11 (1) Answers

Identify differences in text paragraphs with R

I would like to use R to compare written text and extract sections which differ between the elements. Consider a and b two text paragraphs. One is a modified version of the other: a <- "This part is the same. This part is old." b <- "This str...
more »

2017-11-29 10:11 (1) Answers

Split string on basis of "/"

I have a string: string s = "1/09/2017 12:00:00 AM"; Output I want to show is 1/09/17 (basically short date). And if string s ="30/09/2017 12:00:00 AM" Output I want to show is 30/09/17 (basically short date). What I have tried is: str...
more »

2017-11-29 07:11 (5) Answers

Strings intersection

I have three variables with string values. Need to find the longest intersection between all three lines. Like so: let str1 = 'abc123efg'; let str2 = 'c123efg'; let str3 = 'abcdefg'; // result -> 'efg' Yet to solve the problem is obtained by u...
more »

2017-11-27 16:11 (1) Answers

Recursive Find and Replacing String?

My question is about finding and replacing strings in a text file. This program is supposed to find the instances of the word ghost within A Christmas Carol text file and replace them with bunny for ghost, Bunny for Ghost and BUNNY for GHOST. It work...
more »

2017-11-27 06:11 (1) Answers

strrpos find second occurrence

in PHP, Why cant I find the second occurrence of "some test" using strrpos function fnd ($a){ $offset = 1; $sTag = "some test"; echo "offset ".$offset ."<BR>"; echo "Start Tag " .$sTag ."<BR>"; $pos1 = strrpos ($a, $sTag, $o...
more »

2017-11-21 19:11 (0) Answers

Search and return multiple text strings in Excel

I have a list of cells in Excel, all in column I. Each of the cells has a list of countries and/or regions. I would like to build a formula that will search the text in the cells in column I for specific strings and return those same strings in the ...
more »

2017-11-21 17:11 (2) Answers

How do I replace a range of characters in Ruby?

With Ruby, how do I replace a range of characters in a string? For instance, given teh string hellothere If I want to replace characters at index positions two through five inclusive with "#" to result in a string he####here How would I do thi...
more »

2017-11-20 04:11 (1) Answers