Questions tagged [string-manipulation]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
64 views

How do I remove parts of this data?

The data: ...
9
votes
3answers
560 views

StringJoin with Spaces

I'm having some trouble using StringJoin --- the problem is that the StringJoin function creates a string where all the words in a list are combined without any spaces (whitespace) For instance, list ...
3
votes
2answers
176 views

Most common prefixes in an English corpus (Hamlet)

There are many resources online showing how to get the most frequent letters in the english language. What I'm trying to do is get the most common word prefixes in the english language - i.e, take a ...
1
vote
3answers
368 views

Changing variable names

In Mathematica, I am doing computations involving polynomials with variables like p[0,1,2] In the end, I will need to put these equations in to another program. ...
4
votes
2answers
67 views

problem of `Shortest` and `StartOfLine` in string match

Say I have the code below to extract those lines with "::" in a string snippet: ...
2
votes
0answers
251 views

How to decode Ascii85 format (AKA base85)?

The ASCII85 encoding is a binary string encoding where every four bytes are encoded with five ASCII letters, using 85 different types of characters. Unfortunately, it's not in $CharacterEncodings: ...
1
vote
1answer
98 views

ReplaceAll with StringContains

I would like to replace lists within a list based on a string pattern with a blank sequence: ...
5
votes
1answer
323 views

Use cases to select subelements by Regex

I have a nested list and would like to select a sub set of lists using a RegEx and I would prefer to use patterns (mainly for readability). ...
2
votes
2answers
4k views

How to Output Lists without Commas or Brackets?

When trying the below code, is there a more elegant way to output the numbers without the commas or brackets? Grid, as suggested in other threads, is not behaving ...
0
votes
1answer
121 views

Getting rid of brackets in strings

I'm very new to mathematica and need help writing to a text file without brackets around my lists of numbers. Currently in the text file my output is like ...
4
votes
3answers
392 views

Deleting certain elements of a list

This query is similar to a question I posted earlier. Given testList = {{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"z", "y"}, {"a", "b3"}}; I would ...
5
votes
1answer
166 views

Eliminating items from list by rule

I have a list: testList={{"a","b 3","cd","ef 23"},{"z 12","y","x"}} and wish to obtain resultList={{"b 3","ef 23"},{"z 12"}} ...
2
votes
3answers
296 views

How to exclude non-western characters from a text file?

I would like to exclude non-western characters and words from a text file. I do not know how to insert the text file here, but I suppose you can do without it. All your suggestions will be much ...
2
votes
1answer
68 views

Convert Negative Integers into Signed Binary?

I'm relatively new to Mathematica and have been struggling with this problem for several days. I have a string of integer data, ranging from -2044 to 2044. So this looks something like {-2044,-2040,-...
0
votes
0answers
20 views

How can I create a variable named from a concatenation of strings and assign it a value created similarly? [duplicate]

I have got a list of strings, a = {"first","second","third"}. For each of those strings I would like to create a variable called "The" followed by its content, so ...
0
votes
1answer
122 views

From capital letter to lowercase

I have the following list ...
5
votes
1answer
232 views

A bug in converting some Unicode characters into FullForm?

Currently I know only one well-documented way to convert all special characters in an arbitrary string into their FullForm: In ...
3
votes
1answer
511 views

Remove the blank lines in a text file

In a text file, there are several blank lines and how to remove all of them in a simple way ? ...
3
votes
1answer
103 views

How can I use a replacement rule to replace a backslash?

I have tried as many versions of the following function, but none work. ...
1
vote
1answer
196 views

How to print strings and numbers inside a While? [duplicate]

I'm trying to print the dimensions of some Vector spaces, but I want to print strings with it so I can read the results more easily. I tried this ...
3
votes
2answers
86 views

Correct 2D representation in a message string

Message knows how to convert an expression (taken as an argument) into a string before it is spliced into an actual message: If I run the following in my terminal ...
2
votes
1answer
57 views

Find all runs in a string containing only numbers

The documentation has the following example to find all runs in a string containing only "a" and "b": ...
4
votes
2answers
346 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
23 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
794 views

How To Extract String Between Brackets/Parentheses

I have the following file: ...
3
votes
1answer
129 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
143 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
377 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
39 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
371 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
180 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
109 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
131 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
265 views

Dataset, use list as header

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

Convert number to string

How can I convert the number -0.000007 to a string -0.000007? I tried: ...
4
votes
5answers
1k 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
311 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
260 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
428 views

Get CountryData from 3 letter abbreviation of country name

On browsing ATP rankings I stumbled on a simple problem ...
0
votes
0answers
43 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
389 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
108 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: ...
10
votes
3answers
716 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
240 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
75 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
103 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 ...
10
votes
1answer
651 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
126 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. ...