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 tagged [string-manipulation]

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

4
votes
2answers
57 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
173 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
94 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
291 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
3k 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
75 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
187 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
149 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
273 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
61 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
98 views

From capital letter to lowercase

I have the following list ...
4
votes
1answer
189 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
407 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
78 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
105 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
85 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
56 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
275 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
21 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
618 views

How To Extract String Between Brackets/Parentheses

I have the following file: ...
3
votes
1answer
107 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
128 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
335 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
345 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
166 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
89 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
97 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
221 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
1k views

Convert number to string

How can I convert the number -0.000007 to a string -0.000007? I tried: ...
4
votes
5answers
857 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
267 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
211 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
356 views

Get CountryData from 3 letter abbreviation of country name

On browsing ATP rankings I stumbled on a simple problem ...
0
votes
0answers
41 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
347 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
97 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
662 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
224 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
73 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
91 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
560 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
115 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
78 views

How to plot graphs with word strings excluded?

I have a data set like below: ...
3
votes
3answers
119 views
9
votes
2answers
452 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 ...