Questions tagged [string-manipulation]
Questions on the manipulation of String objects in Mathematica, and the functions used for these manipulations.
1,205
questions
3
votes
1
answer
86
views
Purple color text related with RowBox
Type the first line of following code and press enter key.
...
3
votes
2
answers
124
views
How to correctly identify a series of adjacency matrices in a text?
I would like to read the strongly regular graphs on at most 64 vertices from http://www.maths.gla.ac.uk/~es/srgraphs.php
...
0
votes
1
answer
50
views
Defining product between table
For the given table, I want to make their dot product as follows.
My pseudocode is given as follows: In order to make the dot product, first the table size should be the same.
...
3
votes
2
answers
57
views
Convert Strings in Variables [duplicate]
I want to convert strings to variables. I want to create the term pionprodg1. I tried to do this:
...
2
votes
2
answers
91
views
How to leave only the filenames beginning with some phrase?
Consider some directory testfolder located in the directory with the notebook. It contains the following files .dat:
...
13
votes
3
answers
439
views
Why does Module slow down StringMatchQ by 180 times?
I knew that Module is slower than With or Block, often by several times. But it surprises me ...
3
votes
2
answers
58
views
Implementing anti-symmetric function on two index and for more in systematic way
In mathematica, I want to impose symmetric and anti-symmetric properties of $S$ and $A$ in general way.
Usually I was working with explicit information
i.e., for anti-symmetric $A$ with two index, I ...
1
vote
2
answers
78
views
Derivate in order to a string
So I have the following expression:
...
4
votes
1
answer
66
views
0
votes
0
answers
19
views
Keyboard shortcut function to copy a regular ExpressionString in order to paste it to Regexr.com?
regexr.com is very helpful when developing regular expressions for Mathematica (=PCRE).
Unfortunately Mma 12.3 (and other versions too) have to escape all backslashes and double quotation marks inside ...
2
votes
0
answers
93
views
Guessing patterns of symbolic series
I have a system of 2s+1 equations, where s can take integer values of {1,2,3,....,n}. Here ...
1
vote
1
answer
36
views
String to expression does not work properly
Consider the following string:
string = "Displacement_0.5_ToDecVol_38_FidLength_50";
I would like to extract the three numbers from it: ...
2
votes
2
answers
112
views
Generating arbitrary equations to pass to NDSolve
I would like to numerically solve (with NDSolve ) the following system of ordinary differential equations, for different, fixed $M$,
$$\begin{array}{c} y_{1}'(t)=Fy_{2}(t)\\ y_{2}'(t)=2Fy_{3}(t)\\ \...
1
vote
1
answer
145
views
Most efficient way to read data from file in Mathematica
So I am having trouble because I am trying to do with Mathematica what is equivalent do "sscanf" with C basically.
I will have a text file with a number of specifications:
data1 data2 data3 ....
3
votes
3
answers
62
views
Duplicated points not labeled when presented to ListPlot as point->"label"
A minimal working example is given via:
...
3
votes
2
answers
157
views
How to import the given file properly?
Consider the following file. It has the structure of a table, with rows like
LHC HNL dipole 0.5 0.00001 e {"HNL dipole", 0.5, 0.00001, 0.}
Here, the ...
10
votes
1
answer
206
views
How can I get rid of Background from a String?
For explanatory purposes I have marked parts of a string with different backgrounds.
But this string is part of some Mathematica expression, which processed. My program worked fine before I added the ...
0
votes
0
answers
49
views
Partitioning set including empty set; P=QRST
Suppose I have $l$ length of words denoted as $P$, I want to divide this set into four $P=QRST$ including empty set, i.e., $Q=R=S=\phi, T=P$.
For non-empty set decomposition, I can do
...
0
votes
0
answers
65
views
ReplaceAll on a list of strings
Does replacing a list of strings have to be this convoluted (with a warning too)? Why can't ReplaceAll natively use string matching patterns?
...
3
votes
2
answers
219
views
Finding a subset in the set of the digits of Pi
Well, I want to find the first position where the digits of Pi are {a,b,c,...,z}. So to find the first n digits of Pi and put them in listform I used:
...
1
vote
0
answers
33
views
How to create a Sort function that does not differentiate between String rule keys and Symbol rule keys
Im trying to Sort Rule-s according to Key-s (or names) but the normal ...
2
votes
1
answer
54
views
Why does the console REPL parse input differently from ToExpression?
In the console REPL, we can see that input is parsed in a certain way, that is not equivalent to simply calling ToExpression on the input string. From math.exe using Mathematica 13.1:
...
0
votes
1
answer
52
views
How to write a Replace Rule that will Iconize all Rules in a List whose rhs are long String-s?
First, let me illustrate what I'm trying to do. FormatOptions is a programming utility that will Echo a given ...
9
votes
2
answers
789
views
Does Mathematica have an equivalent to the Python 'translate' function?
In Python you can make a character translation table with 'maketrans', passing it two strings of the same length. Then you can call 'translate' passing a new string and the table you just created. The ...
0
votes
2
answers
66
views
Analyzing html with string patterns
I have an html-code which should be analyzed with String Patterns.
I would like to find all p-tags which contain a padding-left. And I would like to read out the value of the padding left.
I have ...
2
votes
1
answer
86
views
Parsing HTTP POST request or how to find a string in a byte array
I am a developer of a Mathematica web-server (see TinyWEB). I managed to parse a multipart POST request containing text files, however, it is hard to expand it to any types of binary data like JPEG, ...
0
votes
0
answers
38
views
A problem on the string in SetOptions
I want to change the background of the notebook automatically by
...
2
votes
3
answers
168
views
How to compose a filename with multiple string parameters?
Consider some string parameters: Par1, Par2, Par3. Could you please tell me how to compose a ...
1
vote
0
answers
36
views
A successful StringReplace with an error message [closed]
An example of StringReplace and RegularExpression :
...
4
votes
2
answers
129
views
Changing number formats in strings
Given this (simplified and much shorter than the real case) string:
s="The value is now 3.219209e3, it has grown by 1.06e01 in the last year"
I would ...
0
votes
0
answers
31
views
How might one create a Button that wraps everything hilghlighted with mouse with double quotes similar to Comment/Uncomment?
I find typing doublequotes around characters to create strings a bit annoying because it always slows me down. The doublequotation marks lie right at my achilles heel on keyboards. It's too close to ...
1
vote
1
answer
62
views
Finding the letters in a string of characters [closed]
So I have some strings of characters which size are not constant.
Example: Mystring may appear like "12,!abcdefghaijk,.54" and I want to extract only the letters "abcdefghaijk".
I ...
5
votes
2
answers
268
views
Automated generation of homework questions for line problems
I try to help my children in their subjects, I built a small code so that it has as output questions regarding the equation of the line, but I have not been able to modify it so that the result comes ...
1
vote
0
answers
41
views
Transforming a string to a list of expressions [closed]
I have a string of the following form:
...
2
votes
2
answers
63
views
creating strings from variable depth lists
I have the following dataset:
...
0
votes
1
answer
34
views
String manipulation with partial matching of elements
I have a string list constructed as follows:
lis = {"Abcdef","Ghij Kl"," GHI 01", " ABC 02"}
and would like to rearrange ...
4
votes
3
answers
171
views
Deletion of list elements by rule
I have a string list that consists of elements that have 3 sub-elements:
...
2
votes
2
answers
104
views
Reducing a list of strings to known signature strings
I have a list consisting of string signatures:
lis1 = {"ab","cd","ef","gh"}
I have another list:
...
3
votes
2
answers
168
views
Join non-digit character strings
I have a list:
lis = {"20","ab","Cd","10","E"}
in which I would like to join adjacent elements if they are ...
7
votes
3
answers
350
views
Deletion of string characters by rule
This seems simple:
Given
lis = {"abcd12efcdef"}
I would like to delete all instances of "ef" when it directly follows a digit character, to ...
5
votes
2
answers
125
views
StringCases with string replace and with escape characters
I want to extract url address of all css files inside HTML source.
First output is as expected. But why second and third outputs are different? Notice that only "href" was removed from ...
3
votes
1
answer
57
views
StringPartition vs Partition and StringReplace vs ReplaceAll
I am trying to make substitution cipher solver based on quadgram statistics.
I am now in doubt about how to store ciphertext - whether in string or in list of characters.
I did a little test to ...
1
vote
1
answer
116
views
How to extract the following value from a file?
Consider the following file:
...
-1
votes
1
answer
98
views
How to extract the number from the following string?
Consider an archive a.gz with the file a.hepmc containing the following strings:
...
2
votes
1
answer
62
views
create string for string seen in FullForm
Can we create a string for a string seen in FullForm ?
This question is hard to explain/understand with just words.
So explain with an example :
Can you create a function ...
0
votes
0
answers
23
views
Difference between SubstitutionSystem and StringReplace
I'm examining two-step substitution model:
First step, division: {"A" -> "BC", "B" -> "AC", "C" -> "AB"}
Second step, merging: {&...
3
votes
2
answers
95
views
Importing multiple files with filename conditions
I have multiple pictures I would like to import all at once. The filenames range from "000001.tif" to "000200.tif." I am having a hard time importing multiple images after looking ...
0
votes
0
answers
28
views
Column only show one line for multi-line string
Column[{"abc"}]
shows
abc
But
Column[{"a\nb\nc"}]
only shows
...
3
votes
1
answer
215
views
How to correctly sort string list based on numeric substring pattern?
I'm having a hard time sorting a big list of filenames. I've tried a bunch of things, and tried to adapt this answer but seemed over-killing(?)...
...
5
votes
2
answers
151
views
Is it possible to write a faster StringTemplate? [closed]
This post is related to this one
Let us see extremely simple test
...