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
1
vote
1answer
61 views

Compute the length of each string in a set [closed]

Say I have done some computation, and it gives me the following set of string: ...
1
vote
1answer
30 views

Convert string to executable code

This is what I have done to turn the string to executable code. ...
0
votes
3answers
65 views

Repeating strings and shifts of these

I am dealing with things coded as a binary strings. We can think of these as binary expansions of angles on the circle. Suppose I take something with a repeating binary expansion like $\frac{3}{7} = \...
-3
votes
1answer
59 views

Permutation Combinations Mobile Pattern Codes [closed]

Please help write codes to determine 4 to 6 dot patterns. I am stuck after permutations input. It would really help if one could write direct so I could copy paste code to determine list of 4 to 6 dot ...
0
votes
1answer
24 views

Problem with exporting text

I prepared in Mathematica some long text: text = string1 <> string2 <> ... <> stringn; (some strings contains TeX code). Then I would like to ...
2
votes
1answer
40 views

Counting the number of elements

I have the following output: {{{0, 1}}, {{1, 1}, {1, 2}}, {{2, 1}, {2, 3}}, {{3, 1}, {3, 2}, {3, 3}, {3, 4}}} Using Length[] on ...
2
votes
1answer
37 views

Why exported text ends with a highlighted percent symbol?

I have recently updated Mathematica to 12.1. Whenever I export strings as text now, as in the following MWE: ...
4
votes
2answers
209 views

What is wrong with function `LetterCounts` and other functions that operate on strings?

I have noticed that many functions that are meant to operate on string are slower compared to similar functions that operate on lists. One example: Counts versus <...
3
votes
1answer
68 views

Comparing two strings - code optimization

I want to compare two strings by counting how many common characters they have at the same position - but overall in all possible alignments of the two strings. ...
7
votes
0answers
58 views

Export Strings without quotes to a CSV file [duplicate]

Would like to export a List of Lists to a CSV file. Would like the strings in the exported file to not have quotes around them, which doesn't appear to be the default behavior. Is there an option ...
1
vote
2answers
62 views

Finding position of specific substring within string

Is there a simple way of finding the position of a specific instance of a substring within a string? For instance, in the sentence "Bob bought his car at the car dealership". Something like <...
8
votes
2answers
367 views

How to remove any words containing two adjacent characters with different in both cases and letters?

I have a list of permutations of ABCabc and I want to remove any permutations with two adjacent characters with different in both cases (uppercase and lowercase) ...
3
votes
3answers
336 views

Delete Characters from a list

I have a list which contains multiple words and unsupported characters as well : for eg: {é, â, ê, î, ô, û, c, re, be} I want to remove all of the above characters ...
7
votes
1answer
156 views

StringJoin in Thread not working

Here is what I have tried first. Thread[f["x", {"1", "2"}]] ...
5
votes
2answers
248 views

using regex to find a specific word

I want to find the word "circle" and "circles" in the list. list = {"circle" , "picircle" , "circles" } The regex ...
-1
votes
1answer
30 views

Accessing Elements in a nested list

I have nested list of the form: (which I don't want to flatten :) ) lol = {{"hello", "bye", "bye", "Hello"}} How do I ...
2
votes
3answers
81 views

Multiple Calculations in a condition

I want to add and subtract 3 from a list. pos = {82,84} If[# > 3, (# - 3) && (# + 3)] & /@ pos the output I want: ...
3
votes
2answers
249 views

Last part of a url (after the “/”)

I want the last number after the "/". How can I do that? "http://arxiv.org/abs/math/0208009v1" I just want 0208009v1 I want to import multiple ...
0
votes
1answer
34 views

Comparing elements in a list and ignoring white space

I have two lists with element entries. I want Mathematica to identify an element in an opposing list such as Ag107 to be the same as Ag 107 ignoring any space. Each different element occurs only a ...
0
votes
0answers
22 views

Return Link with XML Element

I am trying to import multiple links. I just want the link after ...
1
vote
1answer
43 views

Converting Dynamic Variable to String for use in an API

I am trying to create a code that concatenates a series of dynamic selections (year, month, day) to a string for creating a dynamic date string for use in an API which is to be included in a ...
1
vote
1answer
23 views

Construct string argument and pass it to command

My Mathematica variable scope is set to Notebook, more about it here: What is my current scope if I change `Inspector>Cell options>Evaluation options>...
8
votes
2answers
328 views

Inverse of StringReplace

Suppose I have the following StringReplace rule ...
3
votes
3answers
123 views

Extract substrings with defined length from a string

I have a string like this one str = "this and that but also thit and that"; Now I want to extract, the first 3 letters before and after " and " ...
2
votes
2answers
115 views

How to program a situation like the following in mathematics and generalize the process to other configurations?

Distribute the numbers from 1 to 10(view image) so that the sum of each row and each column is the same and a) the maximum possible b) the minimum possible (I put it from 1 to 10 for ease) I know it ...
2
votes
0answers
33 views

What's going on with \> and \< in strings? [duplicate]

What exactly do \> and \< do in Mathematica strings (e.g. "ab\>c")? They ...
1
vote
1answer
47 views

String manipulation to automate file export

I have a lot of files in a directory that I import using files = FileNames["*.csv", "/Users/jazz/Downloads/second_data_set"]; I can then import each file in <...
4
votes
1answer
50 views

Name of patterns cast as expressions from strings

I'm trying to match a part of a string while imposing conditions on the patterns, e.g.: StringCases["223", a: DigitCharacter ~~ b: DigitCharacter /; Unequal[a, b]] ...
2
votes
3answers
107 views

How to add the capital letters to Caesar´s Code?

This code only works for lowercase letters, how can you add the capital letters? ...
1
vote
0answers
47 views

How can I convert the Defer result to a String

I have created a package.wl where I am building a simple interface with input fields and buttons to generate and solve some simple integer logarithms. There is a button [show solution] that explains ...
5
votes
2answers
146 views

Grouping list elements according to a condition

I have a list of "calls and responses", which are pairs of a message and then either a $0$, for a call, or a $1$, for a response. There is some amount of calls, and some amount, potentially unequal, ...
2
votes
1answer
35 views

Quotation marks inside a list [closed]

I want to place quotations for every element in a list. I am trying this col = Table["\"" i "\"", {i, 0, 5}]; and I am getting ...
1
vote
0answers
22 views

How to make function return SymbolName or alternate name string if a function parameter is given [closed]

Abstract: I have a function objectName[...] that works just fine for variables (symbols) set to numerical results or strings which returns their unevaluated ...
2
votes
0answers
40 views

How to copy and paste special characters out of Mathematica [duplicate]

I'm doing a bit of string manipulation, and the output has Greek characters in it. I want to be able to copy and paste those Greek characters out of Mathematica and into another file. For example, ...
0
votes
1answer
54 views

Use Mathematica to edit TeX file

I have a large (>300 page) latex project split across multiple .tex files that I have decided I want to change some notation around in. A minimal working example would be a main file ...
2
votes
1answer
37 views

Saving Matrices/Lists as Strings

I would like to save .txt file with string matrices, possibly doing some string replacement the matrices delimiters and arranging output for symbolic expressions. ...
2
votes
1answer
50 views

No need to use Alternatives to construct alternative string patterns?

I am trying to match a list of strings with a pattern, in which there are several possibilities for the characters to be matched. To me, the following looks the most natural way: ...
9
votes
2answers
279 views

Removing banal words from a list

NB: I am aware of the DeleteStopwords symbol. I want to remove from a list of words the ones that are likely to be more banal. So for instance if we have ...
4
votes
1answer
82 views

Problem with StringPosition[] and slowness of Import[] in sentiment analysis

Using the post by J. Kinlay at Market Sentiment Analysis we can employ a simple yet effective Mathematica implementation for sentiment analysis in trading. Everything is very clear and useful in the ...
9
votes
1answer
363 views

How to reproduce Wolfram Language's base64 encoded string with command-line tool?

With Wolfram Language: In[7]:= ExportString["foobar中文", "Base64"] Out[7]= "Zm9vYmFyXDo0ZTJkXDo2NTg3" With the closest command-line software I could think of <...
2
votes
1answer
35 views

Remove parentheses in a List

I want the output to be: a,b when the input is {a,b} . How do I do this please? Flatten command does not work.
4
votes
0answers
35 views

Odd behavior of StringReplace and other replacements—but only in certain contexts

When defining a function that uses StringReplace[...] on the lhs of a rule, StringReplace seems to balk at named patterns and ...
0
votes
0answers
29 views

Construct string pattern for two different types of lines

I need to increase my understanding of string patterns. My specific problem is that I have a definition of a type in SystemVerilog that has lines that are either single-bit or multi-bit. I want the ...
2
votes
1answer
47 views

Pattern to match any differential of a certain variable

I'm trying to come up with a pattern or just implement a function DifferentialEquationQ so I can have another function assume different behaviour when it's input is ...
5
votes
4answers
194 views

Transforming input text into code

I'm trying to code a text. I created the code and I put the code to each individual unique character in the text. My map now looks like this: ...
13
votes
3answers
489 views

How complete is the WL's string language?

Consider the following example: Suppose I am interested in words that contain all the letter of the list characters={"e","t","l","a","b"} at least once. An example ...
3
votes
1answer
197 views

Shannon-Fano coding in Wolfram

I'm trying to make a function that codes a string of text using the Shannon-Fano method. I get characters using the CharacterCounts function, and I want to make a ...
2
votes
3answers
250 views

Unexplained Error "StringJoin: String expected at position 1 in #1<>

I have a list genus, containing the list of genus group names for some fishes I work on derived from a column of imported data: ...
2
votes
4answers
128 views

Test for list member positions

Let's say there is a list like: l1={1,2,3,4,5,6,7,8} If you're given some arbitrary element and a distance, how do you find the of list elements that are that ...
4
votes
1answer
72 views

Problem with Get'ting files with << as opposed to Get

When trying to import some files into my Mathematica notebook, I wanted to use ToString to specify the file path. Consider the following MWE, where we export some ...

1
2 3 4 5
21