Questions tagged [string-math]

Use this tag for questions related to string mathematics.

is used in its general concept, in any programming environment, and should be used for questions related to mathematical operations with strings, e.g. Get the string that is the midpoint between two other strings.

12 questions
14
votes
2 answers

Get the string that is the midpoint between two other strings

Is there a library or code snippet available that can take two strings and return the exact or approximate mid-point string between the two strings? Preferably the code would be in Python. Background: This seems like a simple problem on the surface,…
Chris Dutrow
  • 48,402
  • 65
  • 188
  • 258
2
votes
3 answers

Replace part of text in a dynamic string

Let’s take this string has an example: D:/firstdir/Another One/and 2/bla bla bla/media/reports/Darth_Vader_Report.pdf I want to cut the first part of the path: D:/firstdir/Another One/and 2/bla bla bla And replace it with **../**, and keep the…
Marco
  • 1,272
  • 6
  • 22
  • 33
2
votes
2 answers

TSQL - Locating first occurrence of value in a string

I need to run a simple select statement for a column called AddrZip to show all records that contain '1/2 ' after the first space in the column. In Access 2007 it would be: **Left([Names],InStr(1,[Names]," ")-1), but can't find out how to do it in…
Sue
  • 21
  • 1
  • 2
2
votes
4 answers

Vectorize this strfind loop

I'm looking to vectorize this loop: needle = [1 2 3]; haystack = [0 0 1 2 3 0 1 2 3; 0 1 2 3 0 1 2 3 0; 0 0 0 1 2 3 0 0 0]; for ii = 1:3 indices{ii} = strfind (haystack(ii,:), needle); end indices{:} indices then…
1
vote
1 answer

How to determine a match between 2 JSONs?

I have two data sources, and both of them return JSONs. I want to ensure that there is some percentage of match (overlap of data, if you will) in the two JSONs, so as to collate them and store in a single record. Is comparing the entropy of the two…
theTuxRacer
  • 13,709
  • 7
  • 42
  • 59
1
vote
1 answer

Replacing a string in PHP

I am working on an app that gets text as input and gives Sequence Diagrams as output, something like Web Sequence Diagrams. So, for a default input, like Alice says Hi to Bob, the input is: Alice -> Bob: Hi The users can give any kind of inputs.…
0
votes
0 answers

Find numerical values in a string, perform arithmetic on the all numbers in the string, and output a new, revised string containing new values Java

I need to perform arithmetic operations on numbers in a string. I understand that I'll need to parse those numbers out, convert to int, do the math, and then convert back to String. Example: n = 2. Input data: "The building is 350 feet tall with a…
TronChaser
  • 21
  • 2
0
votes
4 answers

How to convert a semantic version shell variable to a shifted integer?

Given a shell variable whose value is a semantic version, how can I create another shell variable whose value is (tuple 1 × 1000000) + (tuple 2 × 1000) + (tuple 3) ? E.g. $ FOO=1.2.3 $ BAR=#shell magic that, given ${FOO} returns `1002003` #…
StoneThrow
  • 5,314
  • 4
  • 44
  • 86
0
votes
1 answer

Adding numbers with large digits in python and how to avoid issues with line breaks

I am trying to solve a problems that involves a number with around 5100 digits. The question asks to find all the 150 digit numbers inside the 5100 digits and sum them together. The question wants you to give the first ten digits of the resulting…
Goose9192
  • 107
  • 1
  • 6
0
votes
3 answers

How can I perform a mathematical calculation on real numbers stored as strings?

I have a class that contains values that are sometimes monetary values (such as 1.25, 2.50, 10.00, etc.) but can also be the string "N/A"; thus, they are declared as string: public class PriceVarianceDataExtended { public String ShortName { get;…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
0
votes
1 answer

string operations in 'R' , Need to substract one string from other, find the A - B of list

> string1 [[1]] [1] " DEV U 1" [[2]] [1] " DEV U 3G" [[3]] [1] " DEV U 4G" [[4]] [1] " THY 4M" [[5]] [1] " THY 5M" [[6]] [1] " THY 6G" > string2 [[1]] character(0) [[2]] [1] "3G" [[3]] [1] "4G" [[4]] [1] "4M" [[5]] [1] "5M" [[6]] [1]…
vinsent paramanantham
  • 953
  • 3
  • 15
  • 34
0
votes
1 answer

how to get specific pattern of sub string from string c#?

how to get specific pattern of sub string from string in c# code? input string like this => "number": 123,"object":"a": "b", "d","e": "f"2233"""""king" sub strings in string array as => "number" "object" "a" "b" "d" "e" "f" "king"