Questions tagged [string-manipulation]
Questions on the manipulation of String objects in Mathematica, and the functions used for these manipulations.
1,322 questions
2
votes
3
answers
135
views
Shortest strings surrounded by other strings
This is probably trivial, but it has been quite a long time since I last used Shortest and now I can not figure out how to do the following properly.
Shortest ...
2
votes
1
answer
130
views
Finding position of corresponding parentheses in expression
Suppose we have an expression in InputForm as a string. The task is to find position of corresponding parentheses. For example parenthesis at position ...
3
votes
2
answers
227
views
How to parse a parenthesized arithmetic string into a minimal-parentheses symbolic expression?
I have arithmetic expressions given as strings with excessive parentheses, and I want to convert them into symbolic Mathematica expressions that retain their structure but are formatted with only the ...
0
votes
0
answers
15
views
Fibonacci word generator and Density of Fibonacci subwords
Reference: arXiv:2505.00602
Reproduce Table I
...
7
votes
1
answer
140
views
What is the behavior of `FromRomanNumeral` on inputs with non-roman characters?
The documentation for the FromRomanNumeral function states that
any combination of valid digits is interpreted as an integer:
...
0
votes
1
answer
139
views
Displaying a string on fixed-width lines
Is it possible to format/style a string/text so that it is displayed in lines of fixed character length like on image without converting it to list of characters?
...
3
votes
2
answers
215
views
How to delete line breaks in imported data
I am having a lot of issues trying to import data into mathematica and then clean the data so that mathematica recognises it. The data is a set of permutations, which I would like to express as ...
4
votes
2
answers
360
views
How to set to 0 all terms in a matrix which contain a minus, revisited
The previous question How to set to 0 all terms in a matrix which contain a minus seems to have a wrong answer. For the matrix
...
1
vote
3
answers
114
views
Converting variable value to a string [duplicate]
I can run this with no problem:
Import[NotebookDirectory[] <> "a10.mx"];
Instead of that, I want to describe 10 with a variable as ...
1
vote
1
answer
90
views
How to parse out a word's position in a data set [closed]
I'm trying to find better ways to import data. My data set is a CSV that contains a parameters at the end of the file. For example in this two part list I want to find the position at which the word &...
6
votes
2
answers
248
views
How to speed up ToString[#,TeXForm]&?
Try the following code to convert the expression to LaTeX code
f = Expand[(x/2 + y/3 + z/5 + 1/7)^20];
str = ToString[f,TeXForm]; // AbsoluteTiming
It took about 1 ...
8
votes
9
answers
918
views
Match two lists based on same elements
I have two large lists:
list1 = {{a,v},{a,h},{b,v},{b,k},{c,t},{c,r},{d,r}};
list2 = {{v,dc},{v,rt},{h,kl},{h,oi},{h,po},{k,ö},{k,dc},{t,re},{r,qw},{r,ay},{r,ül}};
...
0
votes
0
answers
124
views
How to get the desired LLM response in string robustly with and without using regular expression rules
I am trying to query a large language model from VS code using WolframEngine.
However, ImportSting with JSON options does not ...
1
vote
1
answer
110
views
How to separate a filename from its extension [closed]
Is there a function that separates a filename from the extension? E.g.
MyNotebook.nb
would become
...
5
votes
3
answers
826
views
NYT Spelling Bee puzzle
I've written some code that provides answers to the daily NYT Spelling Bee puzzles which ask you to find words that can be constructed from 7 given letters, one of which must be present in each word:
<...