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
4 votes
2 answers
389 views

Largest integer between 1 and 1000 with no letter "n"

This problem is easy to solve logically - try it for fun if you want before you run the code and see the answer. ...
Vitaliy Kaurov's user avatar
0 votes
1 answer
63 views

How do I copy what I enter into 'InputField' without any computational processing?

I made an InputField where I input the quoted sentences inside. And I set InputField to copy every time I run it. ...
Hoony's user avatar
  • 1,460
1 vote
0 answers
57 views

DigitQ, LetterQ, UpperCaseQ, LowerCaseQ on empty string

Is this a bug or I am missing something? #[""] & /@ {DigitQ, LetterQ, UpperCaseQ, LowerCaseQ} ...
azerbajdzan's user avatar
  • 9,693
10 votes
8 answers
447 views

Element by element concatenation of two string lists

I have two lists of strings: month = {january, february, march} year = {2013, 2013, 2013} I want to concatenante these element by element with the final result of ...
Todd Dixon's user avatar
2 votes
3 answers
77 views

Convert a string with $N^2$ entries to a rank-$N$ matrix

Suppose we are given a set of numeral data like a string that consists of $N^2$ entries, say $N$ is very large (here $N=8$ for simplicity, but $N$ can be $10^8$...) ...
zeta's user avatar
  • 21
3 votes
1 answer
81 views

Problems that occur when converting to PDF files using NotebookPrint

I made a string expressed in StandardForm format. ...
Hoony's user avatar
  • 1,460
3 votes
2 answers
174 views

Select a subset in the bit-strings with even 1s overlapped - thank you

Model 1 Consider the permutation list of 4-bit-strings: list = Permutations[{0, 0, 1, 1}, {4}] which outputs: {{0, 0, 1, 1}, {0, 1, 0, 1}, {0, 1, 1, 0}, {1, 0, 0, ...
wonderich's user avatar
  • 903
4 votes
1 answer
209 views

How to execute a String code in the form of StandardForm?

How to execute a String code in the form of StandardForm? I want to get execution results for strings of various forms. For this, I used ToExpression. ...
Hoony's user avatar
  • 1,460
3 votes
1 answer
164 views

How to convert the string "A^0" into the expression Superscript[A,0]?

I'm looking for a procedural way to define a symbol for a variable, based on a string. For instance, ToExpression["A^B"] gives us ...
JuanC97's user avatar
  • 560
1 vote
1 answer
64 views

Two Subscript/Superscript questions

In mathematica code, I have a table of quantities that involve subscripts and superscripts. I need to put short text titles in the first row of the table. Suppose I have index1="A", index2=&...
matrixbud's user avatar
  • 425
0 votes
1 answer
50 views

Exact rules applied by StringReplace when two substrings are to be replaced?

I am interested in the case when we apply StringReplace to a string searching for two substrings where one is contained in the other and we define different ...
tell's user avatar
  • 320
3 votes
5 answers
414 views

Convert integer to words of specific length

Assume we give the value from 1 to 26 to alphabets a,b,...,z. Now given an integer ($n$) i like to generate words of specific length ($l$) that sum of them equals $n$. For instance, if $n=10$, $l=3$; <...
asad's user avatar
  • 838
1 vote
3 answers
562 views

Can colors be included in strings?

Colors are displayed in output like squares of the corresponding color. Say, if input is Blue, the output will be a blue square. I would like to use this in a ...
მამუკა ჯიბლაძე's user avatar
2 votes
4 answers
132 views

How to transform the data in the following way?

Consider the following data: ...
John Taylor's user avatar
  • 4,642
1 vote
0 answers
81 views

Convert a string of Python expression into Mathematica expression within Mathematica

While there are many ways to convert a Mathematica expression into other Languages, I was wondering if there is something reverse for Python. There are some discussions in Python groups, but I am ...
BabaYaga's user avatar
  • 1,604
1 vote
1 answer
50 views

How do I select a long part of a complicated expression between two symbols inserted for the purpose? [duplicate]

I want to select a long expression that spills over into many pages. Using mouse and cursor makes it go really fast. Is there a way I can insert some characters and instruct Mathematica to pick up ...
Quasar Supernova's user avatar
0 votes
1 answer
77 views

How to select a long part of a complicated expression between two symbols inserted for the purpose? [closed]

I want to select a long expression that spills over into many pages. Using mouse and cursor makes it go really fast. Is there a way I can insert some characters and instruct Mathematica to pick up ...
Quasar Supernova's user avatar
2 votes
2 answers
162 views

How to declare a string as unescaped after storing in a variable?

Continuing from my previous question, this issue is an extension of it. This issue is somewhat similar to how-do-i-make-a-string-literal-without-having-to-escape-backslashes? but not entirely the same,...
licheng's user avatar
  • 2,005
1 vote
2 answers
95 views

Can you recover the original vectors that, when summed together, achieved a particular criteria

I am wondering if it is possible to take the binary strings of length $3$ (tuples) whose sums have weight $2$ (i.e they have $2$ non-zero entries)(binary case, meaning they have two $1$'s entries) $$u ...
QC123_367's user avatar
  • 481
8 votes
8 answers
636 views

String containing characters in the same order as other string

How can I write a function that checks whether the characters in the first string are in the same order as in the second string? Examples: ...
Suite401's user avatar
  • 4,313
2 votes
1 answer
35 views

StringReplace with Style will cause another character in the string [duplicate]

StringReplace["abbaabbaa", "ab" -> "X"] will output XbaXbaa, but ...
Y. zeng's user avatar
  • 425
2 votes
3 answers
116 views

Space cannot be used in vertical string with unicode character

To reproduce the issue, use Ctrl+Enter to create 3 placeholders and enter (or ...
Y. zeng's user avatar
  • 425
7 votes
4 answers
222 views

Move variables to one side of equation

I have a bunch of linear equations of the form x[1] == 5012 - 5x[3] - 2x[4] + 5x[7] etc. Specifically there is one linear variable on the left, and the right-hand ...
Facieod's user avatar
  • 175
0 votes
2 answers
108 views

How to automatically convert sub- super-indices to strings?

Consider the following expression: expr = "\!\(\*SubscriptBox[\(m\), \(t\)]\)" I would like to convert it to the ordinary string e.g. ...
John Taylor's user avatar
  • 4,642
5 votes
5 answers
263 views

Cleaning up a string list

I have a very poorly-formed list of football scores: ...
Suite401's user avatar
  • 4,313
2 votes
2 answers
121 views

How can we replace strings according to requirements?

In a text, we need to replace whitenode with yellownode only when the character 'a' appears within the last pair of {} in each ...
licheng's user avatar
  • 2,005
2 votes
2 answers
151 views

Reading the contents of a file into a list

I would like to read the contents of the file.txt into a list of the following form: {1,0,1,12,0,1,0.25,0.012,0,1,0.25,0.026,0,1,0.25,0.057,0,1,0.25,0.090}. How could this be done? In these variants, ...
Mam Mam's user avatar
  • 1,753
6 votes
6 answers
508 views

Application for StringDelete

I have a list of strings: lis:= {{"123 abc def 456"}, {"ghi jkl 789"}, {"012 mno pqr"}} and I would like to remove digit characters ...
Suite401's user avatar
  • 4,313
1 vote
2 answers
98 views

How to extract the following data from the file?

Consider the following file. It has the form ...
John Taylor's user avatar
  • 4,642
0 votes
0 answers
37 views

Turn string with () as function brackets into expression

I have a text file with an equation where all the brackets are formatted as (). For example I read in the equation 2*(Re(a)+Im(b)) as a string. Now I am wondering if I can make this into an expression ...
PhPanda's user avatar
3 votes
2 answers
179 views

Importing a text file of values and converting it to table

I just started using Mathematica. I got some output in a txt file from some computations in Pari/GP which looks like this: $$ [1,2,3,4; 5,6,7,8]$$ Here I want to import the data into Mathematica and ...
Aditya Ghosh's user avatar
1 vote
2 answers
55 views

How to distinguish these strings when extracting parameters?

Consider the following list: ...
John Taylor's user avatar
  • 4,642
2 votes
0 answers
62 views

Pick position of a particular list in the list of lists [closed]

Suppose I have some following lists with different size ...
phy_math's user avatar
  • 801
0 votes
0 answers
44 views

Define or remove a long form input \[xyz]

There are "InputAliases" ⵗxyzⵗ, "InputAutoReplacements" xyzspace, and things we'll call "long form inputs" \[xyz]. It's easy to view and modify the former two ...
Adam's user avatar
  • 3,897
1 vote
0 answers
61 views

Byte array to String with no internal processing, e.g. 𓃰

UTF8 defines a way to map from bytes to glyphs. In particular, glyphs with code <128 can be 1 byte, glyphs with code <2048 can be 2 bytes, etc. up to 4 bytes. For instance, the white queen <...
Adam's user avatar
  • 3,897
4 votes
2 answers
123 views

Selecting sublists from a ragged array of lists of strings

A ragged array of strings with a mix of sublists is processed to output some sublists and not others. The sublists to output have a date, data, and information; in no particular order. The information ...
ChuckD's user avatar
  • 51
3 votes
3 answers
86 views

Selecting particular data with a particular string at-first

I have a dataset and I want to select the only data that starting with C_i (where "i" is a numeric with variability). Here is my dataset: ...
P Pyne's user avatar
  • 441
9 votes
4 answers
2k views

Find Roman numerals up to 100 that do not contain “I"

The question is from Elementary Introduction to the Wolfram Language, section 28 Tests and Conditionals: Find Roman numerals up to 100 that do not contain “I”. What am I doing wrong that the following ...
QC123_367's user avatar
  • 481
5 votes
2 answers
89 views

Is there a difference between a (general) pattern and a string pattern?

I have a list myList that contains several strings. I wish to use Position to find the positions of strings in ...
Andrew's user avatar
  • 10.4k
0 votes
1 answer
46 views

String in a Box representation makes a subtle error

...
imida k's user avatar
  • 4,047
9 votes
4 answers
614 views

Check if a string is a date

I have a list of strings, {"BD4675365", "Corp", "Managers", "Syndicate", "2021-03-08", "8434926"} and I ...
apg's user avatar
  • 2,027
4 votes
1 answer
141 views

Is it possible to improve efficiency of the function?

I have the following function scriptQ to check whether an expression is a "script" or not. This function is frequently called by others, so I need to ...
Lacia's user avatar
  • 2,208
5 votes
3 answers
662 views

Split string at first space?

How can I split a string at the first space character in it? For example, "First I. Last, Jr." should become {"First","I. Last, Jr."}.
murray's user avatar
  • 11.8k
1 vote
2 answers
148 views

Associating a string variable with a numeric variable

There is a translation operation from a numeric variable to a string variable: a[i_, j_] := Symbol["a" <> ToString[i] <> ToString[j]] How ...
Mam Mam's user avatar
  • 1,753
2 votes
2 answers
93 views

Map, applying list in a defined function

Suppose I have defined some function (This is arbitrary) F[alpha_,a_,b_,c_]:=List[alpha,a+b+c] I want to apply this F for a given huge list of sets ...
phy_math's user avatar
  • 801
3 votes
2 answers
131 views

Small trouble with variable referencing in StringReplace?

I am trying to do the following: Take a string abcdEFGpcf and replace whatever is between abcd and ...
Red Banana's user avatar
  • 5,121
4 votes
2 answers
82 views

Decomposing input to two list

Suppose I have $j[1,a1,a2,a3,a4,a5]$, I want to extract this as $\{1,\{a1,a2,a3,a4,a5\}\}$. --My first trial: Using the command Split, I can make ...
phy_math's user avatar
  • 801
1 vote
2 answers
145 views

Extract coordinates from the Gaussian09 calculation file

...
我心永恒's user avatar
  • 1,402
0 votes
0 answers
18 views

For given rules, discard some rules by imposing conditions

For a given input, and after some implementing conditions I want to discard unnecessary rules and pick only relevant rules. More explicitly, suppose I have a following transformation rules. ...
phy_math's user avatar
  • 801
3 votes
2 answers
244 views

How to. automate nutrition calculation

Given a vector of quantities: fbs = {6.18*10^6, 2.663*10^6, 1.4735*10^7}; I like to create the following code: ...
Tugrul Temel's user avatar
  • 5,470

1
2 3 4 5
26