Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

4
votes
2answers
201 views

How to extract all sub-strings of string with a specified start and end using StringCases? [duplicate]

How can I find all the (non-overlapping) substrings that start with a specific string of characters (e.g. ">>") and end with another specified string (e.g. <...
1
vote
1answer
20 views

How to convert string of data into format with quotations?

How would I be able to convert a single string to a string of data? An example would be converting: data= AMD AAPL FB SNAP MSFT into the format: ...
3
votes
4answers
577 views

How To Extract String Between Brackets/Parentheses

I have the following file: ...
3
votes
1answer
98 views

How to use StringTemplate for code?

Say, I want to write a MMA script using StringTemplate, so I can insert additional pieces of code / expressions wherever ...
5
votes
1answer
117 views

What is the difference between the second argument of ToString and its option FormatType?

Is there any real difference between ToString[expr, form] and ToString[expr, FormatType→form]? In all my examples, they seem to ...
7
votes
3answers
306 views

How to convert input expression to FullForm String

Is there a way to convert an input expression to FullForm String? Here is my attempt, which is almost there. ...
0
votes
1answer
38 views

Taking variables from string

In a mathematica operation I am getting the o/p say, 1->2. For the next step, I want to use these two numbers as variables, say take them as 1 = m and 2 = n. How can I do it.
17
votes
1answer
326 views

String operation 1000X slower for special characters

It seems that the string operation is very slow if we have special characters in the string. Consider this example, ...
4
votes
3answers
164 views

Using StringExpression in file name

I would like to open the file "myfile.cdf" or "myfile.nb". One or the other will be in the directory but not both. Because I don't know which, I'm trying to use ...
2
votes
1answer
86 views

Reshape output of TeXForm into one-line string

I am using Mathematica to generate some Matlab code. In order to have a bit of documentation I would like to have a commented line in the Matlab file which holds the Latex form of the original ...
3
votes
1answer
87 views

Convert characters to binary?

I can get a binary representation of characters as follows: BaseForm[ToCharacterCode["A"], 2] However, that produces a weird binary code object that might be ...
0
votes
2answers
201 views

Dataset, use list as header

I have a dataset with a header for row and column which consists of binaries, e.g.: ...
3
votes
1answer
859 views

Convert number to string

How can I convert the number -0.000007 to a string -0.000007? I tried: ...
4
votes
5answers
809 views

How to convert string to real numbers when there are many spaces in them?

I have generated a string list " 1 1 3212 8.0000 75 61 1 74 3 58 0.0000" I want to convert them into real numbers however, when ...
0
votes
0answers
24 views

Function seems to be evaluating before giving it a value [duplicate]

I'm trying to take a list of coordinates and convert the right ascensions and declinations from h min s / deg arcmin arcsec to degrees. This is my list of coordinates ...
4
votes
2answers
261 views

Using FromDigits to convert number strings to numbers

I've loved mathematics for a very long time but am only now beginning my journey to learn to code. The attached image shows the two different outputs (out-5, out 6) for a simple crypto-cypher I'm ...
4
votes
2answers
195 views

Extract string words from string [duplicate]

Hi i'm new to programming and it's my first question, so please go easy on me. I want to create a function that extracts text which is between BEGIN and ...
4
votes
3answers
329 views

Get CountryData from 3 letter abbreviation of country name

On browsing ATP rankings I stumbled on a simple problem ...
0
votes
0answers
40 views

Exporting a large number of image variables in mathematical 11

I used the following code to import a large number of tiff images into notebook. ...
6
votes
3answers
340 views

Characters to numbers

I have an string "000101". I know that Characters change it to {"0","0","0","1","0","1"}. ...
13
votes
4answers
1k views

How to remove unknown zero-width character from string?

I have text that contains a zero-width character that I am not able to remove. A minimum example is in str below where the character is at the start of the text. <...
0
votes
1answer
92 views

Manipulating through color schemes in ColorData

So I wanted to manipulate through both the color schemes and the RGB color within that scheme but encountered a problem. I started by defining a function: ...
9
votes
3answers
634 views

ROT13 and upside-down text (flip text)

How can we transform text in order to achieve ROT13 and flip text using Wolfram Mathematica? 1. ROT13 2. Flip text
4
votes
5answers
217 views

DeleteCases based on string length

I have the following dataset data = {{"one", "two", "three", "a", "b", "c"}, {"four", "five", "d"}} I want to delete all the strings with length < 2. The ...
5
votes
0answers
72 views

Helping Mandy become a better speller [duplicate]

tl;dr Can you improve upon this code, which checks to see if a word can be spelled using the element symbols from the periodic table? I recently created a periodic table that lights up. The design ...
0
votes
1answer
84 views

Parse large ASCII matrix

I am parsing a large ASCII sparse matrix, output of PETSc, but my current implementation is impossibly slow. I don't know how I could speed that up. The ASCII file of a sparse PETSc ...
9
votes
1answer
510 views

How to export strings as pure ASCII?

The "PrintableASCII" characters set consists of 97 characters, including space (\[RawSpace]) and two control characters: the ...
5
votes
2answers
108 views

Possible bug in Export with CharacterEncoding -> “PrintableASCII”

In the Documentation we read (emphasis is mine): By default, the Wolfram System uses the character encoding "PrintableASCII" when saving notebooks and packages. ...
1
vote
2answers
73 views

How to plot graphs with word strings excluded?

I have a data set like below: ...
3
votes
3answers
116 views
9
votes
2answers
449 views

How to extract a value from an XML tree

I am trying to pull out a certain value from an XML tree that I have acquired from a website: ...
5
votes
3answers
147 views

Applying different values to string row

This must be easy but I'm stuck, I want to create this row: {< 1 >}{< 4 >}{< 4 >}{< 22 >}{< 3 >}{< 12 >}{< 54 >}{< 65 >} from this list ...
4
votes
2answers
180 views

convert from a dataset to list

I have a Dataset of only 1 column to start with, and I want to StringJoin every element there. Got the error message ...
7
votes
4answers
381 views

RegEx replacement with backreference followed by a numeric literal

I have a text file which contains lines of the type: SYMATTR InstName U1 where "1" can be actually a number with 1 to 3 digits. I want to replace the above line with the following 2 lines: ...
2
votes
1answer
38 views

Unwanted additional output of a function that manipulates string [closed]

I would like to write a function which produces a table of the frequencies with which various letters of the alphabet are found in some textual input. Here is what I did: ...
5
votes
2answers
73 views

How to match numbers to alphabets with period and space,

ToCharacterCode["ABCD...XYZ"] - 64 I know that I can make a list of alphabets in this way. However, I need to assign " " and <...
0
votes
1answer
44 views

Recalling the value of a previously defined variable and the Today Date inside Export?

I am using Exportto obtain a.jpg file. I would like that in the file name a specific value (defined as a variable "gama" in the code) appears. I would like to find ...
4
votes
2answers
256 views

How to find a longest word path in dictionary?

Cross post here A word path means the last character of the last word is same to the first character of the next word.And the path have no duplicated word.If I have $55$ words,I can find it with this ...
2
votes
0answers
67 views

Convert variable name to filename [duplicate]

Is there a way to convert any variable name to a string that would be a valid filename (under Linux and Windows)? Specifically, I would like Greek letters to be replaced by a spelled out form or just ...
4
votes
3answers
392 views

How to Add strings into each element of a list [closed]

This is a rather basic question but as I am new to programming, I have been stuck on it for a little while. I am trying to add strings to the beginning and end of every element in a list (each element ...
2
votes
1answer
98 views

Replace string in a expression

After looking for an answer for 2 hours I give up and hope someone can help me out: I have the following expression: ...
5
votes
1answer
94 views

Regex named groups — how to refer back to them in the replacement string [duplicate]

We can use group numbers to reuse the same piece of code while inside regex string, like that: StringCases["x = y", RegularExpression["([\\w\\s]+)=(?1)"]] <...
3
votes
2answers
315 views

Finding the number of syllables in a string of text

To implement a readability algorithm, I need to find the number of symbols in a long string of text (almost 5000 words). There doesn't seem to be a built-in Mathematica function that can count the ...
3
votes
2answers
72 views

Isolate first order elements

How can I isolate only the first order "h" terms in the following expression? ...
21
votes
1answer
537 views

Why Except is so slow as compared to equivalent RegularExpression?

When comparing performance of the solutions suggested for this question I discovered that StringExpression involving Except is ...
4
votes
1answer
222 views

How to convert TeXForm to String via ToExpression without it being evaluated in between?

I looked at similar questions, but could not find an answer. I need to convert Latex that represent pure mathematical expressions generated by Maple to Mathematica. I do not want to actually use ...
8
votes
1answer
215 views

How to include a backquote in a message?

NB: I know one suboptimal solution to this problem, which I give at the end. I'm looking for a better one. Also, I was not able to solve this problem with the solutions give in Backquote in string ...
4
votes
3answers
217 views

Extract substring up to specific character non-inclusive

I was wondering if there is a way with StringCases to start at the beginning of a string and stop one character before a known character. ...
-1
votes
2answers
101 views

How to loop a StringCount command with different specifications

what I want to do is count how often different date combinations appear in a string,"March 2004" till "March 2017" basically. I used ToString and StringJoin to create the searchable string and then <...
0
votes
1answer
165 views

Specifying precision of a number in StringForm[]

I want to use StringForm to provide the headers to a table of numbers I have just calculated. Basically, I want the top row of spots in the table to have the form $D = x~~\text{(nm)}$, where x ...