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

learn more… | top users | synonyms (2)

6
votes
2answers
179 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
78 views

Simple string pattern crashes kernel

The following code crashes my Mathematica kernel (v9, MacOS): ...
2
votes
0answers
33 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 ...
1
vote
3answers
55 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 ...
4
votes
5answers
511 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 ...
1
vote
3answers
110 views

Manipulate strings within a list

Let's say I have Solve[x^4 + 3 == 0, x] with output ...
30
votes
6answers
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. ...
6
votes
3answers
184 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 ...
4
votes
3answers
67 views

Question about Replacements and String Manipulations

I'm trying to get better at Mathematica and in the book I'm using (by Nancy Blachman) is the following question (which apparently was taken from another book: The Art and Science of C) which reads: ...
13
votes
2answers
426 views

How to embed an image into a string?

Note: The bug described in the post is in Mathematica 9, and has been fixed in 10.0. The documentation for String contains the following statements: Strings ...
3
votes
3answers
108 views

Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? Eg. Convert ...
7
votes
0answers
194 views

How to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?

I have an opened Mathematica notebook containing several cells. Suppose, I am interested in one of them -- it may contain a complete or incomplete expression (e.g. with syntax errors, highlighted ...
2
votes
1answer
79 views

How to efficiently process pasted content from PDF

I had selected a matrix in a PDF file, and paste it onto my MMA notebook. Below is the exact copy-pasted content: ...
5
votes
3answers
500 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 ...
11
votes
2answers
175 views

ToExpression fails with long nested string expressions

Consider the following conversion from String to Mathematica Expression: ...
5
votes
1answer
108 views

Dataset and string conversion, using Internal`StringToDouble

i'm trying to get familiar with the new Dataset-stuff in Mathematica 10. As it will (hopefully) provide some benefit for me, I have started to convert my app to move from list and list of rules to ...
-1
votes
3answers
81 views

How do i import a list of files, choosing the name

I have this list of files, i'm using FileNames[{"*.txt"}, NotebookDirectory[]] to import it, but i just want the ones without inelastic on the name. How can i select just by the name? Thanks ...
2
votes
3answers
69 views

Table to text string [closed]

I know this is a simple question and there is a single command to do this but I have been looking for the command for 30+ minutes and cannot find it. I have a list that I want to put tabs between ...
3
votes
2answers
57 views

Can StringTemplate be extended to offer printf-like formatting capabilities?

Apparently, Mathematica has no real sprintf-equivalent (unlike any other high-level language known to man). This has been asked before, but I'm wondering if the new ...
0
votes
3answers
55 views

Positions of a string in a list [closed]

Sorry for the bad title..Didn't know how to describe this, feel free to change it to be more specific. I have a list in this form: ...
1
vote
1answer
28 views

StringCases: return list of outputs for each of several patterns

According to the documentation, StringCases[{s1, s2, ...}, p] returns {StringCases[s1, p], StringCases[s2, p], ...} but, ...
5
votes
3answers
226 views

String templating

I am pretty new to string processing in Mathematica. But I'm having some problems in doing simple string template filling to my mind elegantly. For example when doing export for my answer here, one of ...
2
votes
2answers
59 views

Using Table with arbitrary number of variables [closed]

Let $P=\{p_1,...p_n\}$. I would like a way to implent Table[Expression,{$p_1$,lim},{$p_2$,lim},...,{$p_n$,lim}] where n and lim are parameters defined by the user. Any ideas?
0
votes
0answers
40 views
3
votes
1answer
69 views

Convert an expression's symbols of form a$x to a[x]

I want a function that takes expressions of the following form: a$x and converts them to a[x]. In particular, consider the ...
6
votes
3answers
254 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: ...
0
votes
1answer
80 views

Converting strings of the form “1.34e5” to real numbers? [duplicate]

ToExpresssion doesn't understand real numbers of the form "1.34e5". How do I convert the string ...
2
votes
2answers
79 views

Find names similar to a given name in a large data set

I'm trying to find a 'similar' name to every item in a list ...
2
votes
2answers
101 views

how to take some parts of String with certain pattern

I have the large number of files in which the file's names follow certain pattern. for example here are names of two files ...
8
votes
1answer
105 views

CSS Selectors for Symbolic XML

Symbolic XML is a convenient way of managing XML in Mathematica, at least for casual use or small tasks. Here and elsewhere you can find examples of XML handling in Mathematica, including XSLT/XPath ...
2
votes
2answers
90 views

Importing Data and Devoting Their Names to Them

There are some files in a directory. I have used of SetDiroctory to access all of them. SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; I can visit ...
1
vote
2answers
46 views

Alternative to Except in StringExpression when using StringMatchQ

According to this answer and the documentation for StringExpression, Except can only be used in StringExpression for classes of ...
0
votes
0answers
18 views

How would I take a variable from a string and reassign its value? [duplicate]

If I have string={a,b,c}, where a=1, b=2, and c=3, how would I reassign a value to variable "a" without directly typing a = _? If I type string[[1]], the out put is "1". How would I generate the ...
0
votes
1answer
47 views

ToExpression and Fortran notation

ToExpression["9.0E-03"] interprets String as 9*e - 3 instead of what I am expecting ...
3
votes
2answers
102 views

Converting unevaluated lists to strings

I have a list like l = {2 - 3, 12 - 4, Times, aab} I want to end up with {"2-3", "12-4", "Times", "aab"} I have tried ...
4
votes
1answer
144 views

Selectively converting numerical strings to expressions

I have a list of strings representing different types of data ...
3
votes
1answer
184 views

How to extend dictionary.txt

How to extend the default dictionary.txt for Dictionarylookup to all words? For example, first I ...
3
votes
6answers
752 views

Getting a String from a list of strings

Is there a way to write down Mathematica with a string such as: {"M","a","t","h","e","m","a","t","i","c","a"}?
2
votes
3answers
224 views

Treat strings as variables?

I have a list of strings, {"x1", "x2", "x3", "x4"} And a list of linear equations: ...
0
votes
0answers
33 views

StringCount in Mathematica

StringCount["one letters three letters letters one letters letters three letters", "one" ~~ __ ~~ "three"] gives 1 because ...
2
votes
1answer
48 views

StringExpression: pattern reapeted one or more times matches pattern repeated zero times

I try to construct patterns using Riffle and Except StringExpression@Riffle[{"a", "b", "c"}, Except[{"=", ","}] ..] and expect it to match "a_b_c", but not ...
2
votes
2answers
1k views

Faster way to convert real strings into numbers [duplicate]

Working with big files, I have to convert some numbers that are in string format into real MMA numbers. I know that I can use ToExpression but it's slow when ...
0
votes
1answer
63 views

Generalizing Characters to n-character substrings [duplicate]

I'm doing some frequency analysis on an encrypted plaintext. Tally[] and Characters[] make the basic task quite easy. To count the number of times each character appears (sorted alphabetically; ...
3
votes
1answer
85 views

Converting string representation of boxes into explicit boxes

It is very easy and convenient to write textual labels as Strings in the WYSIWYG mode. For example, I define a short form describing a linear model: ...
10
votes
1answer
210 views

StringReplace, ReplaceAll and Rule interact in a bizarre way

I have the following pair of things: ClearAll[foo, labeledFoo]; labeledFoo = {"FooBarBazQuux", foo}; This works like you'd expect: ...
2
votes
1answer
88 views

Generating the set of all strings within a fixed edit distance of a initial string?

Provided a starting string initialString, and a particular alphabet of allowed characters {"A","B","C","D","E",...}, how can I ...
3
votes
2answers
101 views

How do we make a negative integer out of a string of a negative number and vice-versa?

Negative numbers are not taken into consideration by mathematica's built-in functions. FromDigits["-2"] Gives me this message: ...
3
votes
2answers
87 views

Finding all instances of length $N$ common subwords in two strings

Given a pair of strings, I'd like to return a list of all common subwords of a fixed length of "n" characters (i.e. contiguous subwords of length "n" that occur in both strings), allowing for ...
14
votes
4answers
865 views

Converting a large floating-point number to a single-line string

When I feed a large (or small) enough floating-point number to ToString, it produces a two-line string, with the first line containing only the exponent of 10: ...
4
votes
1answer
76 views

What string pattern will match $n$ contiguous characters drawn from a given alphabet?

I'd like to use StringCount to count the number of subwords in a string that have the form **** where ...