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

Inconsistent behaviour using string with superscript as label

This might be a silly question, but actually I lost a bit of time to figure out what I was doing wrong and now I want to understand better. Moreover, I'm not sure if the behaviour I see is a bug or ...
2
votes
1answer
53 views

How to specify optional string parameters in a function signature and identify the pattern

As a newbie, I've got a rather simple question. I would like to define a function that accepts one of a few possible strings. I.e., I wish to do the following. ...
5
votes
0answers
50 views

Pattern for string that does not contain x, constrained to shortest matches only [duplicate]

I need a pattern for a string that does not contain a specified string, while at the same time respecting the mandate to match only shortest sequences. For example strings bracketed by ...
1
vote
1answer
60 views

Is this decryption function idiomatic?

This is my first non-trivial Mathematica notebook, which I wrote for a cryptology homework. It encrypts/decrypts strings using an affine cipher. Is the code readable/idiomatic? How could it be ...
4
votes
1answer
128 views

Jaro distance in MMA

I'm trying to program Jaro distance as requested by this page I've done the following code that works well for the next two pairs ("MARTHA", "MARHTA") and ("DIXON", "DICKSONX") but when I try with ("...
0
votes
0answers
52 views

How should I import list of results with scientific numbers so they can be used for further calculation?

I have a file, listOfResults.txt, consisting of many rows of which the following is an example: ...
0
votes
0answers
73 views

How to rasterize huge fonts

If ...
0
votes
2answers
108 views

How to properly write fraction in style

I would like to write the following for the legend of a curve : $$ Theta = \frac{\pi}{2}$$ Where the value $\frac{\pi}{2}$ is actually in a variable named $Theta$ (same name as the text on the lhs ...
1
vote
2answers
43 views

Changing the style in a list

I have the following list, l={{"a", "b"}, {"c", "d"}} I was wondering how can I convert it into: output: {"ab", "cd"}
0
votes
1answer
89 views

Generating list of labeled string [closed]

I want to generate a table that gives the following output: output: {"x1", "x2", "x3", "x4", "x5"} I have tried: ...
2
votes
4answers
156 views

Splitting a binary number into smaller parts and converting each smaller part back to decimal

This is my first Mathematica post and I would be obliged if you could be patient with me. I have the following large binary number $1111010010001001100011010101111110000101101110110011100101$ which I ...
3
votes
2answers
247 views

Deleting unwanted spaces in a list of string

I have a badly structured data and I need to clean it up, suppose I have the following list: l={{"a","b","c"},{"e"," f","g"},{" a"," b"}} As you can see they ...
7
votes
2answers
234 views

Select UPPER CASE list items with spaces and punctuation

I have a sample list that includes people's names in Title Case, and their companies in UPPER CASE. ...
11
votes
3answers
329 views

StringContainsQ And

I'm looking to test whether a string contains all substrings in it, independent of each substrings location. For example: ...
1
vote
1answer
82 views

Symbol Level pattern matching and rule replacement

I want to parse a Mathematica Notebook to get some information regarding the relative use of symbols. So first things first: ...
9
votes
3answers
476 views

Number of capital letters

I am interested in counting a number of uppercase letters in the text. I do it in the following manner. ...
0
votes
1answer
60 views

StringPattern: Not one of pattern?

I have read in a Mathematica notebook and have assigned its content to the variable file. I have created the Strings corresponding to Wolfram Language symbols as ...
3
votes
1answer
146 views

Splitting a text file into smaller text files by line numbers using Mathematica

Is it possible to split a large text file into smaller files by line numbers in Mathematica?
2
votes
1answer
99 views

DeleteCases not working as expected

I am trying to reproduce the example of Data Cleaning from here. I had to make a slight change in input 13 to ...
3
votes
2answers
40 views

How to return a default value if no match is found in search of string

Suppose I have a string like "a-1_b-2_c-3_d-4" with numbers, labels, and separators, and I want to get ...
0
votes
0answers
22 views

create a list with common head [duplicate]

How to create a list like below by Table #& or others? j1, j2, j3, j4 ... j15 ...
1
vote
0answers
70 views

How to write a power using `WriteString` function

I have a solution of an equation: aa = N[Rationalize[g6[[3, 2]], 0], 16] (* Out: 2.691607147352649*10^-6 *) I want to save this result in a file using ...
1
vote
1answer
257 views

Visualize Zipf's Law

I want to visualize Zipf's Law Zipf's law states that the frequency of a word is inversely proportional to its rank I tried: ...
4
votes
1answer
105 views

How can I get better formatting in ToString?

ToString (and thus Export) has a tendency to mangle the nice structure of Mathematica expressions as they are generally coded. ...
5
votes
1answer
77 views

How to speed up a text search widget?

I have an InputField that searches a predefined list for matching strings and displays them in a TextGrid. But when the list is ...
2
votes
0answers
43 views

Confusing behavior for GrammarRules and GrammarApply

I have been experimenting with GrammarRules in an attempt to create a parser for text downloaded from the web. I have been using Interpreter to help understand the behavior of GrammarApply. Here is a ...
0
votes
1answer
47 views

Help with actions in EventHandler

I am trying to write a program where the user types on the keyboard in a specified location, and Mathematica outputs what you are currently typing, plus a prediction that is updated in real time of ...
2
votes
2answers
62 views

StringForm with named arguments

StringForm with named arguments In python, this is possible: example: a = "{x}, {y}".format(x=5, y=12) print(a) result: ...
3
votes
1answer
100 views

Deletion of list elements containing a string character

I have a list: lis = {"ab","a-1","1-20"} from which I need to delete elements of lis that has (only) digits on both sides of the hyphen, in each element that ...
5
votes
3answers
120 views

StringCases and DatePattern: something strange

May be that I did not understand something about Mathematica pattern matching, but I noticed what follow: st is a string, inside the string there is a date (...
4
votes
2answers
74 views

Pulling sections from a webpage

I'm trying to get specific sections from a webpage using Mathematica. I've started by importing the webpage, and getting the section "headers" that I want: ...
1
vote
0answers
53 views

Reconstructing a partition from its character

Given a solid partition $\rho=\{\pi_1, \pi_2, ..\}$, where $\pi_a$ are plane partitions such that $\pi_{a+1} \subset \pi_a$, we can compute its character, which is a sum of monomials with non-negative ...
10
votes
5answers
451 views

Separate string at upper case letters using StringReplace

Is there a way to turn AbcDefGhi into Abc Def Ghi by using StringReplace? The following ...
5
votes
2answers
175 views

Data Cleaning Problem - Getting rid of redundancies

I am cleaning a database and I need to clean also the location field. The data is taken from a forum, so the entrance are self compiled. For this reason I have a lot of weird and different stuff going ...
5
votes
1answer
81 views

Convert a numerical expression to words

I would like to convert algebraic sums of the form 8+1-3 into words, obtaining "eight plus one minus three". I have tried using ...
13
votes
1answer
206 views

Safe alternatives to ToExpression

Background Conversion from string/boxes to expression is quite common. Very often the goal would be a simple switch from "1" to ...
4
votes
1answer
74 views

Searching for substrings in large text document?

I have a large text file that I need to search for certain substrings and I would like to use the speed-up that TextSearch gives. Unfortunately, with ...
4
votes
2answers
256 views

Splitting nasty list FAILED

I am still a beginner with Mathematica and I have a simple problem with splitting this list: ...
1
vote
1answer
49 views

Manipulating definitions while reading them with Get

In order to read in a definition with certain parameters replaced by appropriate values I can use for example Block[{a=1.1,b=2.2}, Get["file"]] where ...
1
vote
1answer
70 views

Is there a function to convert an English description to an expression?

I know I can write: SpokenString[a + b^2] And then obtain as output: "a plus b squared" What about the opposite, something ...
0
votes
0answers
56 views

Why does StringReplace wrap StringExpression around result?

The task is to separate a leading separator from subsequent text into a list. Why does StringReplace wrap StringExpression ...
2
votes
1answer
28 views

Import File prevent splitting of sentences

I have a file that looks like this on Notepad When I import it, I get this: ...
2
votes
2answers
92 views

How to tell whether a character is a letter-like form

Is there any way to programmatically tell whether a given character is a letter or letter-like form (see this reference page for what I mean)? One idea I had was to use ...
1
vote
2answers
135 views

Extract values from a string list with string elements like “ Id=\”1\“ ”

I have a simple problem which I am not able to work around. I have this list ...
0
votes
1answer
75 views

Evaluate until a regexp match is satisfied

How do you express the computation that, given a list of regular expressions, perform a replacement until one of them is satisfied. For instance: ...
5
votes
2answers
901 views

Function to translate from English to Morse

I am trying to write a function that takes English text and produces the corresponding Morse code. I have a function which works fine when the text consists of lower case letters. But I could not ...
2
votes
2answers
110 views

Searching words with the five vowels

after looking for a long time manually words in Spanish that have the five vowels in any order, for example Republicano, murcielago, superiora, etc; I'm bored and without success. I thought that ...
10
votes
2answers
313 views

Unscrambling jumbled anagrams

I know that we can easily check to see if a string contains any anagrams by the following snippet: ...
6
votes
5answers
191 views

How to interpret a MM/DD string knowing that it lies on a day between two DD.MM.YYYY strings?

I am writing a parser for my banking statements. The structure of the document is a header that, among other things, contains the text Account statement from dd.mm.yyyy to dd.mm.yyyy and a table ...
1
vote
1answer
42 views

Printing out reals in a table with a specified number of digits

I would like to print out an list of reals in a table with perfectly identical number of digits so that they can be perfectly right-aligned. However, once I convert them to strings, ...