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
0 votes
0 answers
30 views

How to search text for a specific word? [closed]

I have a list of text where each position contains a sublist with a length of 12 elements. I'm trying to search for a word can be appears in the first position of each sublist. The desired output is ...
SAC's user avatar
  • 1,335
0 votes
0 answers
28 views

Coverting .nb file code content to string type using NotebookImport

For my work I need to import the notebook and get all the contents from the code cell. For this task I chose ...
ordenarion's user avatar
2 votes
1 answer
45 views

Intra-Symbolic Wild Card Pattern Matching

I have the following custom expression structure I am parsing: Theorema`Knowledge`Q$TM[ Theorema`Language`VAR$[Theorema`Knowledge`VAR$x$TM]] I already was able to ...
marie_antoinette's user avatar
3 votes
4 answers
167 views

Sort Column as a Row

I have a = {1, 2, 3, 10}; b= {2, 3, 4, 8}; t= Do[If[a[[i]]+b[[i]]>3,Print[a[[i]]],"No"],{i,1,4}]; 2 3 10 I need to get the result; t={2,3,10}
Alyasaa Jasim's user avatar
6 votes
2 answers
246 views

Replace number in string with ? and /;

I am trying to make the following: StringReplace[{"A4", "A#3"}, {"A" ~~ x_ -> "B" ~~ x}] This should replace ...
Red Banana's user avatar
  • 5,329
3 votes
0 answers
55 views

How to improve Burrows-Wheeler Transform performance?

I have implemented the Burrows-Wheeler Transform as below: ...
flinty's user avatar
  • 25.3k
0 votes
0 answers
42 views

How to convert LaTeX to expression without interpreting variables as products?

I need to convert some LaTeX code to mathematica expressions. So far I have used ToExpression["ab", TeXForm] yielding ...
Suppenkasper's user avatar
1 vote
1 answer
41 views

Why is StringSplit dropping empty entries? [closed]

I am parsing a CSV and whenever the trailing records are empty: StringSplit[",2,,4,,",","] I get: {"2&...
user13892's user avatar
  • 9,385
1 vote
0 answers
131 views

Butterflied Strings Shortest Character Solution

The shortest character solution for Butterflied Strings on Wolfram Challenges according to the CODE CHARACTERS functionality is 40. I have a solution with 42 ...
Navvye's user avatar
  • 151
0 votes
1 answer
47 views

Pattern matching with DeleteCases

I'm using Mathematica 14.0 and I'm having a pattern match problem with DeleteCases. The example below illustrates the problem. I define a test string followed by two patterns that both nominally match ...
jparm's user avatar
  • 1
3 votes
2 answers
99 views

Writing Mathematica code for putting in commutation relations in a string

I am trying to write a mathematica code to accomplish the following: For a given $n$, consider $(ab)^n$, which is a string of the form $\underbrace{ababab...ab}_{n\text{ times}}$. I want to replace $...
Ryan Hendricks's user avatar
1 vote
1 answer
58 views

Compressing a file's name string

I was working with files where each name records a lot of information about what is in its respective file and wanted to compress it a little bit. So I wanted to change it's 'base'. And I noticed that ...
Teg Louis's user avatar
2 votes
3 answers
225 views

The problem of matching consecutive cross-line strings

I have a file named "s0.log",There's a lot of this structure in there: You can see that the strings "Alpha occ.eigenvalues --" and "Alpha virt.eigenvalues --" will be ...
我心永恒's user avatar
  • 1,562
1 vote
0 answers
62 views

Why is SequencePosition or SequenceCases so slow on large lists?

I observed that SequencePosition or Sequence Cases on a list of around 60'000 digits is so slow that I had to sort out to string pattern matching. Is this normal behavior or should Wolfram have a look ...
markilux's user avatar
  • 121
3 votes
4 answers
263 views

How to select elements from a list of strings?

...
Tugrul Temel's user avatar
  • 6,203
3 votes
1 answer
115 views

Behaviour of `ToExpression` inside a function definition

I want to create a function that takes in an array of unknown size and do some index operations on it. I am using strings to construct the expression and then trying to use ...
Himanshu Chaudhary's user avatar
3 votes
5 answers
136 views

Sorting logic and generation of letter sequence

In the context of experimental designs, it is common to generate the various treatment names to build the factorial design table. The table of the 2^2 design reads : For the 2^3, the table reads : ...
Jocelyn Minini's user avatar
2 votes
1 answer
59 views

FromLetterNumber and "" bug or intended behaviour

DigitQ behaviour appears consistent "" is treated as 0 by DigitQ` ...
IntroductionToProbability's user avatar
1 vote
1 answer
57 views

Difficulty using StringCases to obtain desired substring

I have extracted and stored some plaintext strings (derived from a pdfs) from the web that I wish to search for various values following certain text substrings that are different for different ...
Stuart Poss's user avatar
  • 1,883
2 votes
1 answer
67 views

RawBoxes in ClickToCopy adding spaces after escaped characters

I'd like to use ClickToCopy to display a matrix equation, and have its TeX form be copyable. I started with something like ...
srossd's user avatar
  • 260
3 votes
3 answers
251 views

From string to number

I have data such as, {{[Part(33.0, 34.0), Part(33.0, 34.0), Part(31.0, 32.0), Part(30.0, 32.0), Part(29.0, 32.0), Part(28.0, 29.0), Part(28.0, 29.0)]}} as text ...
rani's user avatar
  • 321
1 vote
1 answer
83 views

Nicer display of output with TeXForm

I am summing some terms by first transforming it to TeXForm. Example: Sum[TeXForm[x^i],{i,1,50}] I want to break the line in ...
BabaYaga's user avatar
  • 1,836
1 vote
0 answers
30 views

Change specific elements of a list [closed]

I have currently looking to change specific elements of a list. I saw that you can apply a fonction to an element if you know it's position as shown in this question : Apply function to specific ...
Student_Number_249812341's user avatar
1 vote
0 answers
27 views

Can I limit the mouse prompt position in InputField? [duplicate]

I wrote the Manipulate code in double quotation marks in InputField. Manipulate[str, Style[Control@{str, " "}, 20]] Above, I can create a prompt status ...
Milk's user avatar
  • 1,688
4 votes
2 answers
611 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
70 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. ...
Milk's user avatar
  • 1,688
2 votes
0 answers
69 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
  • 16.7k
10 votes
8 answers
462 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
3 votes
3 answers
87 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
  • 251
3 votes
1 answer
88 views

Problems that occur when converting to PDF files using NotebookPrint

I made a string expressed in StandardForm format. ...
Milk's user avatar
  • 1,688
3 votes
2 answers
176 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
  • 923
4 votes
1 answer
222 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. ...
Milk's user avatar
  • 1,688
3 votes
1 answer
178 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
  • 612
1 vote
1 answer
74 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
  • 435
0 votes
1 answer
56 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
420 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
566 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
134 views

How to transform the data in the following way?

Consider the following data: ...
John Taylor's user avatar
  • 5,733
1 vote
0 answers
103 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,836
1 vote
1 answer
51 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
78 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
182 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,029
1 vote
2 answers
98 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 ...
am567's user avatar
  • 501
8 votes
8 answers
642 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,833
2 votes
1 answer
36 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
  • 567
2 votes
3 answers
131 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
  • 567
7 votes
4 answers
253 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
113 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
  • 5,733
5 votes
5 answers
268 views

Cleaning up a string list

I have a very poorly-formed list of football scores: ...
Suite401's user avatar
  • 4,833
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,029

1
2 3 4 5
26