Questions on the manipulation of String objects in Mathematica, and the functions used for these manipulations.

learn more… | top users | synonyms (2)

1
vote
1answer
32 views

Creat a global variable from an argument and being able to use it as a numeric input

I want something like this: myfun[j_]:=Block[ {ans}, ans = Range[j]; "phi"<>ToString[j] = Total[ans]; ]; The procedure is just an illustrative ...
0
votes
1answer
45 views

TraditionalForm for PlotLabel with a parameter

This is a simple variation/spin off of this question, but I am having trouble. In the second example in the original question, I'm trying to get the $a=$ in the ...
31
votes
1answer
509 views

Why is StringExpression faster than RegularExpression?

Edit: as noted by Albert Retey the performance difference is only seen when sub expression extraction is performed. If this test is used below the timings are similar: ...
0
votes
2answers
65 views

Turn a string into a list of strings [on hold]

Is there a way to turn a series of letters, say: "kspe" Into a list composed of strings (not variables) in the form of ...
6
votes
4answers
576 views

Caesar's cipher

How can Caesar cipher be implemented? I want to use StringReplace but I don't know how to write the replacement rule to replace the characters with, say, the ...
4
votes
3answers
351 views

Camel hump string split

Given System names of 2 or more characters: systemNames = Names["System`*"] // Select[StringLength[#] > 1 &] ; Is ...
3
votes
3answers
187 views

String pattern defined by number of characters

I want to extract non-overlapping substrings from strings with only four possible characters a,b,c,d. These strings will always have equally many "a" and "d" characters. The substrings x I want satisy ...
15
votes
3answers
460 views

Grabbing a number of characters around a string pattern

If I have some string data: text = StringTake[ExampleData[{"Text", "DeclarationOfIndependence"}], 400] "When in the Course of human events, it becomes ...
28
votes
4answers
3k views

Looking for “Longest Common Substring” solution

I'm looking for robust code to solve the "Longest Common Substring" problem: Find the longest string (or strings) that is a substring (or are substrings) of two or more strings. I can just code it ...
15
votes
1answer
361 views

Why is TextString[-0.5] a positive number?

I want to format numbers in decimal notation and chose TextString for this task. But today, when looking at the final result of my 3-weeks measurement, the sign ...
6
votes
3answers
171 views
2
votes
1answer
31 views

Linear function on strings using UpValues

I have two functions Sup and Sdown that take a string of letters with allowed characters ...
6
votes
1answer
158 views

Returning computable numbers from WolframAlpha

WolframAlpha["Apple company revenue", {{"Result", 1}, "Plaintext"}] Desired output 182800000000 ...
1
vote
1answer
48 views

Insert a linebreak and character repeatedly into a matrix output which is in fortranForm

Suppose I have a very long string which is a11 element of matrix a11=2*gopsv-2*Bgopsvw+2*acgmops*v+2*cgmopsv*B-2*acgmopsvB+3*gmopsvB-3*BgmopsvwB+m*w2*B +5*acgm2 +opsvB -ac*m2*w2*B +cgm2*opsvB* - ...
35
votes
8answers
4k views

How do you convert a string containing a number in C scientific notation to a Mathematica number?

Suppose I have a string containing the C-representation of a floating point number, for example s = "1.23e-5" and I want to convert this to a Mathematica number. ...
3
votes
2answers
69 views

Removing non-word characters in certain parts of a string

I would like to ask how I can remove non-word characters from a string, but only in certain cases. I have read this article, so I know how to get the words out of a string. My text is however a bit ...
1
vote
1answer
44 views

Importing file as a string causes a puzzle

I generate simple txt file and import it as follows: a = Import["binary.txt"]; b = Import["binary.txt", "String"]. It appears then that lengths of imported strings ...
1
vote
2answers
93 views

How to solve ArcSinh equation for many differents parameters?

I am totally stuck trying to solve the equation below (1/2) x Sqrt[1 + 4 a^2 x^2] + ArcSinh[2 a x]/(4 a) == d Where a and ...
7
votes
3answers
310 views

How to parse information contained in a file name

I have a set of files containing my data, and the file-names contain relevant information that I would like to extract. What I have is: ...
4
votes
1answer
168 views

How do I remove single-character whitespace between words, leaving multiple, contiguous, whitespace characters unchanged?

In a string, I want to remove only the single-character whitespace between printing characters, leaving any multiple, contiguous, whitespace characters between printing characters unchanged? What is ...
2
votes
2answers
146 views

Difference between double quotes

I have a notebook and I enter something like PlotLabel->"my label with dynamic number "<>ToString[strange] and I get errors like However, the double ...
1
vote
2answers
57 views

Generate a sequence of names such as a1, a2, a3 [duplicate]

How do I generate the sequency {disp1, disp2, disp3, ...}? I tried the following but it didn't give me what I expected: ...
3
votes
5answers
200 views

How to join two strings one of which is Subscript?

If I write this one str=Subscript["x","y"]; StringQ[str] False How can I get str as string?
2
votes
4answers
97 views

Finding relevant parts in XML document

My qyestion is about a XML document and finding parts of strings. test = Import["C:\\Users\\filename.xml", "XMLObject"] This gives the following output: ...
2
votes
3answers
162 views

Graph showing valid English words obtained by insertion of single characters

I'd like the most efficient Mathematica code for making a formal tree graph whose nodes are valid English word strings (in DictionaryLookup[ ]) and directed links represent the relation 'insertion of ...
1
vote
1answer
64 views

Transforming a nested list for textual output

Hello I have a data structure based on lists, with items, subitems and subsubitems, and I want to display a textual output with a description. ...
5
votes
1answer
150 views

Conditional string replacement

I have a list of text and need to replace an element based on the text that appears in the element before it. Example of my list: ...
1
vote
2answers
71 views

How to define a function that counts the exponents

I want to define a function $F$ described as follows: The input of $F$ is a polynomial such as m*u*x^4*y + n*v*x^2*y^3 where $m$ and $n$ are constants, and ...
2
votes
1answer
84 views

Convert matrix of strings to matrix of numbers [duplicate]

I have 101 files each with a lot of data. from C output. (.out files) I have imported them to Mathematica 9. However, Mathematica reads the data from each file as an element of a table. So I used ...
0
votes
2answers
71 views

text analysis: split document in seperated lines

For a text analysis I want to split a large document in seperated lines. Then I want to calculated for example the average number of words. A example of the document is the following: ...
20
votes
0answers
239 views

StringCases is Confused with Patterns in Version 10.0.1

I observed the following with StringCases when trying to use rules/patterns. Here is a screenshot of the behavior: Not only is the pattern highlighted in red, ...
2
votes
2answers
49 views

Retain or delete parts of textstring in tweets

For a twitter analysis I collected many tweets. For example: ...
11
votes
1answer
150 views

Bug in Operator Form of StringCases

According to the documentation there's an operator form for StringCases ?StringCases Here is the normal form ...
8
votes
2answers
526 views

A femme is a wife is a Frau

As can be seen from LanguageData["Properties"] // Multicolumn Mathematica's translation capabilities seem to be very limited. It can translate month names, ...
11
votes
7answers
618 views

Splitting strings into letter keys and integers

I have strings of the following form: string = "ABC123DEFG456HI89UZXX1"; Letter keys of variable lengths are followed by (positive) integers. I want to get this ...
5
votes
6answers
939 views

Convert a string into a list of numbers

I got the following problem I don't know how to solve or if it's at all possible to solve(I'm quite new to Mathematica and don't have an IT background, so please explain slowly if possible:)) I'm ...
4
votes
4answers
182 views

Splitting a string into substrings of length 1 and 2

There is already a thread on how to split a string into equal sized chunks. I'm wanting to split a string into sets of substrings of length 1 and 2. For example, if I have the string "123456", my list ...
17
votes
3answers
479 views

Unicode-aware string functions?

I've recently discovered that ToUpperCase is quite unreliable on non-ASCII input: ...
5
votes
1answer
190 views

Sorting an Array with words in different languages

Array consists of words of different languages. I need to sort elements in reverse alphabetical order and make a list of elements, which consist of english letters. Example of array which consist of ...
29
votes
9answers
4k views

Programming paradigm change

I'm new to Mathematica, I've been learning by myself, and, being a Java developer for some time, it makes it hard to adapt. I've tried to solve a Reddit challenge, and I came up with this solution: ...
6
votes
1answer
134 views

Understanding `Paste` and how to get a string from the Clipboard to use with `ImportString`

Trying to work on this question I got distracted by my first naive attempt of copying the data and then typing dat = ImportString[Paste[], "Table"] ...
7
votes
3answers
547 views
7
votes
5answers
354 views

Splitting strings at lower case characters and numbers

I'm trying to split the strings of chemicals into their elements and numbers. See this example "Fe3O4" will be split into ...
6
votes
2answers
238 views

Converting a string into a nested list of strings

The following string can be converted easily into a list with ToExpression ...
5
votes
1answer
101 views

Simple string pattern crashes kernel

The following code crashes my Mathematica kernel (v9, MacOS): ...
2
votes
0answers
43 views

Is it possible to Compile the function with string argument?

As we can see from the Compile documentation, the typical arguments for Compile should be ...
0
votes
3answers
69 views

Unexpected behavior of rule-replacing with string concatenation [closed]

Here's the code. Clear[x,y,z]; {x,y,z} /. x_ :> ("^_^" <> ToString[x]) I get the result ^_^{x, y, z}, which is not ...
1
vote
3answers
119 views

Manipulate strings within a list

Let's say I have Solve[x^4 + 3 == 0, x] with output ...
6
votes
3answers
198 views

Problem with WordBoundary in string patterns

I am trying to extract from a string all words that end with "-man", but the problem is that WordBoundary does not seem to work as it returns whole string ignoring ...