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
0answers
23 views

Example with \$CharacterEncoding [on hold]

I'm looking for an example with $CharacterEncoding = None
2
votes
1answer
66 views

Data in Atom Form

I am loading a dataset into Mathematica and the format is always recognized as an Atom String: DS[All, 4] ...
0
votes
1answer
57 views

Suppressing DateString default behavior when parts of date are missing

By subsampling data from a Excel spreadsheet I have created a Mathematica dataset that I then seek to modify by applying various functions to the fields to convert these data into a different flat ...
1
vote
2answers
43 views

Restrictions as string to expression in region plots

I'm trying to build a function that generate a string of restrictons to pass on to a region plot with ToExpression, but I think it fails to pass the plot variables. ...
6
votes
0answers
65 views

Repeated string pattern: difference between the FrontEnd and WolframScript?

This code works fine in a string based interface like WolframScript or Mathematica Kernel. Run this through a string based interface ...
64
votes
10answers
12k views

How do you convert a string containing a number in C scientific notation to a Mathematica number?

Suppose I have a string containing the C-representation of a floating point number; for example s = "1.23e-5" and I want to convert this to a Mathematica number. ...
0
votes
2answers
94 views

Replacing all integers in a string

Let's say I have some expression like, expr = 1*a + 2*b +3*c + 4*d I want to write this to a string that I can then use in some other Fortran script. I want all ...
1
vote
1answer
45 views

Convert string to conditional operator

I have a RadioButtonBar with a selection x = None; {RadioButtonBar[Dynamic[x], {lt, le, eq, gt, ge}], Dynamic[x]} Once a radio button is selected, I would like ...
3
votes
1answer
40 views

Get subscripts of sum of expression and save each summand's subscript separately

I deal with expressions like A= a_i a_j a_k + a_i a_l a_m+ ... where the a_i notation is shorthand for Subscript["a",i] and all subscripts are integers. In this ...
0
votes
1answer
40 views

WriteLine[] not working once put into a function

I wrote a function that takes two strings, an integer, and an OutputStream, it's supposed to write to. The function is: ...
9
votes
4answers
232 views

How can one convert an expression to a string while keeping the quotation marks of strings that are part of the expression?

How can I for example convert {"a","b"} to "{\"a\",\"b\"}", so keeping the quotations marks.? I tried ...
0
votes
1answer
44 views

How can import more files simultaneously and clean them in Mathematica?

I would like to import three files in Mathematica (I am using the Import function[]) and try to clean them. I used ...
0
votes
0answers
33 views

relating Compress[] to information theory

I have a question regarding the Compress[] function. From my reading, Compress[] is based on zlib and should provide lossless compression. Given a string (call it test), I would expect that, from ...
1
vote
1answer
78 views

Defining functions from strings

Blank symbol (_) is moved when applying ToExpression to the following string: ...
1
vote
0answers
49 views

How can I handle box drawing characters?

I must generate files for windows batch scripting, modifying template files, es. ...
1
vote
1answer
54 views

Function returning a pattern with condition - how to prevent condition to evaluate prematurely?

I figured it would be convenient to have a function that returns a pattern, that match equally nested brackets, of the specified type. Such a pattern is easy to create, but I get some error messages, ...
0
votes
1answer
79 views

How many symmetric words are in a string? [closed]

Determine how many symmetric words are in a given string. https://reference.wolfram.com/language/tutorial/WorkingWithStringPatterns.html
0
votes
1answer
46 views

ToExpression[ToString[x^2]] does not produce x^2 [closed]

ToExpression[ToString[x^2]] does not produce $x^2$, instead it gives $x$. Please explain. I actually wrote the following code and it gave the answer as 1. ...
0
votes
2answers
74 views

Comparing strings within a list of strings

I have a single list containing strings like this: list={"house", "cat", "dog" ,"horse", "horses", "tree"}; How can I compare these strings within a list and ...
3
votes
1answer
34 views

How to remove the trailing ` in StringForm[“Mean `1`”, 2.2]?

How to remove the trailing ` in the following? StringForm["Mean `1`", 2.2] produces Mean 2.2`
0
votes
1answer
50 views

Delete elements form a list with elements with strings and numbers

I am trying to create a list list2 removing elements from a list list. The structure of list...
0
votes
0answers
68 views

Strip of all tags “Defer[…]” from a string expression

How can i remove all "Defer[...]" from the following expression ...
1
vote
1answer
50 views

How to encode the character into UTF-8?

As we know the café is caf\xc3\xa9 after encode by UTF8: >>> 'café'.encode('utf8') ...
2
votes
1answer
47 views

Using StringTemplate with TableForm [closed]

I have a table given by ...
1
vote
1answer
47 views

Change date format for different variants of SQL

Wrote this code to change MS Access variant of SQL date format to T-SQL, basically recognize dates delimited with pounds and change pounds to single quotes My Mathematica code is Pythonic, because I ...
0
votes
1answer
28 views

Count the number of words in WordList that start with a “q” [closed]

How can I create a subset of WordList[] that contains only the words that start with "g"?
6
votes
2answers
416 views

Convert a huge txt-file into a dataset

My friend has this huge txt-log of sea levels. He wants to organize it into a dataset. After importing it this file a used StringSplit to separate it into rows, then to singular elements ...
6
votes
2answers
246 views

Joining strings in lists of strings

I have a list: lis = {{"abc","def","ghi"},{"jkl","mno"}} and wish to get: res = {"abc def ghi","jkl mno"} This: ...
0
votes
0answers
28 views

How to join words in a list to form a single sentence? [duplicate]

If I have a list of words such as: {"If","I","have","a","list","words","such","as"} How can I join all the words in this list and for a single string sentence ...
-3
votes
1answer
46 views

Performing loop operation (average on lists of datas) of strings of datas [closed]

Lets say I have 100 CSV files of two columns data in each file, and I want to calculate the average of the 2nd column of each CSV file and then save all all these 100 averaged values in one CSV file (...
43
votes
10answers
7k views

Programming paradigm change

I'm new to Mathematica, I've been learning by myself, and, being a Java developer for some time, it makes it hard to adapt. I've tried to solve a Reddit challenge, and I came up with this solution: <...
5
votes
3answers
547 views

Delete strings: {name, John, John Doe, Doe} to {name, John Doe}

I am not very familiar with coding and I am trying to solve the following: Input: {name, John, John Doe, Doe} Output: ...
4
votes
2answers
73 views

Function to join variable names

I am trying to define a function that takes any two strings (possibly predefined as variables, functions, etc.) and join them in one string (which can also be predefined and will keep its definition ...
0
votes
1answer
35 views

Extract substring: knowing the starting characters and form

I'm trying to extract a specific part of a long string, where the part of interest starts with "testx" and ends with a number before an underscore follows, so e.g., ...
7
votes
1answer
128 views

Problem to import numbers longer than 19-digit with “JSON” or “RawJSON”

Bug introduced in 11.0.1 or earlier and fixed in 12.0. MMA 11.0.1.0 (Windows 10, 64-bit) I see that "JSON" import can be buggy (154245), so my question is simple: can the following behaviour be ...
7
votes
3answers
315 views

Reading a file as a ByteArray?

I want to read in large files as byte strings. Import[..., "Byte"] yields a list of Integers that takes up much more space (16 times more) than the file. ...
5
votes
2answers
82 views

Sub-subscripts in strings cause different spacings than subscripts

Spacing around subscripts within strings seems to work well: But the spacing around sub-subscripts does not: I did not manually add that space after the 2. How can this be fixed? Thanks!
3
votes
1answer
50 views

Fixing different display colors within string

My question below is my attempt to reduce a problem I am having to the simplest possible version that will show the error I am trying to fix. I recognize that the coding looks tortured, and I will ...
10
votes
3answers
716 views

ROT13 and upside-down text (flip text)

How can we transform text in order to achieve ROT13 and flip text using Wolfram Mathematica? 1. ROT13 2. Flip text
2
votes
0answers
41 views

Bug with TeXForm conversion of superscript in strings [duplicate]

Bug introduced in 10.0 or earlier and persisting through 11.3 Consider a String expression with a TemplateBox superscript: ...
3
votes
1answer
237 views

“Riffle” two strings

I have two strings, e.g., s1="A|P|Q|Z" and s2="r|ss|t|yy", where "|" is meant to be a ...
2
votes
1answer
29 views

How to count the number of characters seperated by a special character in a string?

I have a string in which a special character is treated as the separator. For example, str={aA|B|b|Ca|XYzz}, where "|" is the ...
1
vote
1answer
73 views

How to generate letters for multiple people from a list of names

I need to generate many letters of invitation from a list of people. I thought this would be already asked/answered in this forum, but I can't find anything useful. Basically, I need to write a letter ...
4
votes
3answers
889 views

Create all possible words using a set or letters

Given a list of letters, letters = { "A", "B", ..., "F" } is it possible to get Mathematica to generate all ‘words’ (in this example, 6 letter words), if only ...
9
votes
2answers
430 views

How can I use words/letters as pixels in an image?

I'd like to take the text of a novel or whatever and arrange it in a way that forms an image. Essentially recreating these works from Postertext. (source: litstack.com) . I'm mostly looking for ...
4
votes
2answers
156 views

Commonest[] function doesn't actually show commonest elements

I'm using Commonest function on a list with 500000 words to get the 10 most frequent elements. Then by using WordCloud, I found ...
2
votes
1answer
52 views

Web Scraping - Why are these numbers interpreted as strings?

I started with: data = Import["https://www.destatis.de/DE/ZahlenFakten/GesellschaftStaat/Gesundheit/Todesursachen/Tabellen/Sterbefaelle_Unfaelle.html", "Data"] ...
1
vote
1answer
34 views

Line break a long expression only at whitespace

Suppose I have some long string expression. I want to break this into multiple lines,with an ampersand at the end of each line. My first attempt was of the form, ...