Questions on the manipulation of String objects in Mathematica, and the functions used for these manipulations.

learn more… | top users | synonyms (5)

5
votes
1answer
163 views

Why Base64 ends with a newline? (\n)

Why everything converted to Base64 has a newline at the end? It isn't one of base characters, is it? ...
1
vote
1answer
49 views

Extract pattern from `StringExpression` [closed]

I want to extract a string that is book-ended by two strings. For example, given <em> This is emphasized </em>, I can find the whole string using a <...
1
vote
1answer
50 views

Difference between `StringJoin` and `StringExpression`

When does one need StringJoin as opposed to StringExpression? I don't know of an example where ...
2
votes
3answers
64 views

Cardinality of members of a list [closed]

I have to count all the words in a book. I need the cardinality (occurrence) of all the words. {{Table,30},{the,200},{apple29}, etc... I Splitted, and StringTrimed ...
6
votes
3answers
132 views

Grouping words by their differences

I'm a new guy here and I face a problem. I should pair the following words according to the rule: pair the words, that differ by max. 2 characters, like: ...
0
votes
1answer
31 views

add " for all member of the last (1 and -1 positions)

I have a small problem with a list. I did, that list={AA,BB,CC} and I wish to make it into the form of {"AA","BB","CC"}, but I cant insert ", because failing, I tried simply adding, or MapThreading, ...
1
vote
0answers
46 views

Where can I find documentation on use of special characters in templates?

I am new to Templates. I have seen the usage "\!\(\*StyleBox ...)" as here: disabling templates What does the string "!(*" accomplish and can I find some ...
3
votes
1answer
62 views

StringReverse question

I was thinking about how to make this with the StringReverse, but I failed: I have a sequence of (for example) "FDSRTYNHFNKHLIUHG", I wish to reverse, but randomly long sequence reversed from a ...
5
votes
5answers
446 views

Random character change in a random place

I would like to ask for help in a Random Replace of character. For example: ORANGE and change 1 character randomly (random place and random character from ORANGE) in it into any character of ORANGE, ...
3
votes
2answers
87 views

German Umlaut: how to forward through Run to the say command on OS X?

My aim is to make Mathematica speak out German words with Umlauts. I found a hint how to make use of a help function mySpeak that will forward a string to the say command and set the corresponding ...
1
vote
5answers
397 views

How to repeat a string?

I really can't find a way how to multiply (repeat) strings in Mathematica. How to write this shorter? ...
3
votes
1answer
89 views

How to extract “this text” between specific characters: 1) this text 1)

I have a text file that has thousands of questions and blanks for the answer, like this: 1) This is the first question 1)______ 2) This is the second question 2)______ 3)... What I ...
2
votes
1answer
44 views

Select date and time using string case

I did the following code to get data from a list: Partition[Flatten[StringCases[Flatten[del2], {__ ~~ ":" ~~ _ ~~ ($1___) ..} -> { $1}, Infinity], 2], 23] ...
3
votes
1answer
65 views

Prevent expression from evaluation in function when using `ToString `

I defined function fhold Clear[fhold] SetAttributes[fhold, HoldAll] fhold[para_List] := ToString[para]; What I want is that ...
4
votes
1answer
136 views

Permute list of strings

Say I have a list of strings like slist={"apple","123","Car"} What I want is a list of all permutations of slist. The result ...
2
votes
1answer
60 views

Using strings in defining rules

I am very new using Mathematica and I would like to define a rule of replacement which operates as below, keeping freedom for what concern the pre-factors that can appear in the equation: $$e^{\pm ix} ...
2
votes
1answer
232 views

Replace punctuation marks in strings with spaces

I have a list of strings. Some of them contain commas, single quotes, etc. Is there a quick way to replace those characters by blanks? My list looks something like this: ...
2
votes
2answers
99 views

How to transform data in character form into a sensible form?

I have a data output from a device in a form of a string. I need to transform it into such a form that I can work with it, such as plot columns with respect to one another and such. After a apply <...
3
votes
2answers
105 views

How remove specified substring and everything after it to the end of a string?

If I have, say, the string, txt = "now is the time for all (good) men" then I want to remove the substring beginning with "for" and ending at the end of the ...
5
votes
0answers
58 views

SimilarityRules for SequenceAlignment of two lists

I am trying to use the SimilarityRules option of SequenceAlignment to customize its output. This works perfectly for strings, ...
0
votes
1answer
38 views

Regular expression help for arecord command output

How do I get the card number and device number alone from this string by using a regular expression to parse it? Here's the string ...
3
votes
0answers
50 views

Why was StringRepeat designed so that StringRepeat[s, 0] throws an error?

I'm wondering about the rationale behind the design decision that leads to the following expression throwing an error: ...
8
votes
2answers
307 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. . I'm mostly looking for ideas regarding a ...
3
votes
1answer
69 views

Whitespace is lost during MathML -> XMLElement conversion

ImportString["<mtext> </mtext>", {"MathML", "XMLElement"} ] XMLElement["mtext",{},{}] while I'd expect: <...
0
votes
1answer
82 views

How to implement the for loop to replace text strings or texts?

I wonder define a bunch variables named like $X_1$, $X_2$, $...$, $X_n$. Is there some smart way to declare them instead of by pure typing. One trick I can image is to use the for loop,...
0
votes
2answers
140 views

How to make an Histogram where the data are strings? [duplicate]

Histogram[{3, 3, 2, 2, 2, 2, 2, 1, 1}] works great to give you an histogram in which mathematica counts the occurence of each number and makes the plot. Is there a ...
5
votes
5answers
214 views

Converting set of characters into numbers using list of replacement rules

I am trying to convert a text, as an example "aaaa" into a set of numbers as defined in a list of replacement rules, for example letterstonum . letterstonum takes in letters a to z and returns the ...
2
votes
0answers
34 views

How can I construct a string pattern from a list of patterns? [duplicate]

Is it possible to construct a string pattern from a list of strings? ...
15
votes
3answers
432 views

Highlighting pattern strings in a large text

I would like to apply Style to strings that are matched, for example, with one or more specified patterns or regular expressions, a string or a list of both, ...
2
votes
1answer
59 views

Braces in pattern with Cases function

Here's my problem: I've got a JSON-formatted response and want to match some variables over the response. I'm doing it using Cases: ...
4
votes
2answers
154 views

Printing every other line from input text

I am trying to do some text manipulation in Mathematica. After importing a text file (in.txt) as a string, how would you then output every other line? In the ...
2
votes
1answer
71 views

Having trouble modifying entry in a list

Hi, I am trying to create a small repository by entering three things as a list of string, namely the asp, sequence and description. The trouble that I am facing is that while I am manually running ...
8
votes
1answer
154 views

How to get string representation of boxes in v10.2?

In Mathematica versions up to 10.1 we could get string representation of given boxes by passing them to ToString with InputForm: ...
2
votes
2answers
140 views

Manipulating strings containing backslash

I'm trying to implement some code that downloads files from some webpages. I am using the built-in functions Import and ...
0
votes
1answer
55 views

Avoiding misconversion of data with ToExpression function [closed]

I've got a list of data with the following structure which can be easily converted To expresion by some manipulation such as ...
1
vote
3answers
102 views

Keep leading/trailing zeroes (like Defer except with numbers) in a given number

I'm trying to write a function that counts the number of significant figures a given number has so I can ensure my calculations are rounded correctly; however, I am having a lot of trouble preventing ...
5
votes
3answers
614 views

Finding all of the words containing certain letters

Is there a fast method to find all of the words containing the letters: {a, e, i, o, u, y}? I created an algorithm, but it takes more than 11 seconds to find all of ...
4
votes
2answers
111 views

Using parenthesized Regex backreferences in StringReplace

(I am sorry for my poor English,I'll try to use a simple sentence to convey me.) I can use StringCases to get the target to change like this ...
1
vote
2answers
55 views

Detect Mathematica operators eg. \[CircleTimes] in strings

I'm trying to detect all Mathematica operators/symbols (eg. [CircleTimes], [Colon], etc.) in strings so I can replace them with something else, how can I achieve that?
1
vote
1answer
44 views

FromDigits gives “not a list of digits” error for integer string in StringExpression rule of StringCases

I have large StringExpression that is used in StringCases. Some of the parts being pulled out are integer strings. These pull ...
1
vote
1answer
49 views

How to reference StringExpression named parts from a package without full Context path?

I have a long StringExpression in a package returned by a function. There are some named parts in the expression that I would like to reference when I use the ...
5
votes
1answer
208 views

Escaping multiline strings in Mathematica

I want to assign long multi-line strings in Mathematica. Is there a way of delineating a block without having to escape each instance of '"' with '\"' and each line ending with '\'? i.e. In other ...
7
votes
2answers
126 views

Strange Error on Fresh Kernel (10.2)

Bug introduced in 10.1 I wrote a helper function to format real numbers in a certain format for writing .dbf files here. It relies on a new function to 10.1 - ...
2
votes
3answers
185 views

Problem displaying uppercase “I” in a string [duplicate]

It seems that Mathematica reserves the capital i, I, for the imaginary unit. I have the following expression: expr = a.b + II ...
6
votes
4answers
284 views

Shorter shorthand for StringJoin[]?

As a minimal working example: myString="some words"; myString=myString<>"more words"; Is there a shorter way to tell Mathematica that I want to "tack on" ...
3
votes
1answer
203 views

Using Probability for n-gram string queries

I want to use Probability to ask questions on strings like "what's the probability of the occurrence of the trigram 'the' conditioned on the occurence of the digram 'th'?" This doesn't work. I ...
10
votes
1answer
309 views

How to change the font color of a variable in whole input cell

I want to track the occurrence of a particular variable in a code. So the idea is to change its color. Usually I do it in a crude way - convert the code into text and then use ...
1
vote
2answers
55 views

How to define a function `deriv[f[x]]` such that its output is an unevaluated expression `fx=D[f[x],x]`?

I want to define a function deriv[f_[x_]] such that when I run deriv[f[x]], the output is an unevaluated expression ...
2
votes
1answer
64 views

How to extract part of association?

Considering an association: asc = <|"a"->1, "b"->2, "c"-><|"e"->3, "c"->4|>, "d"->5, "e"->6, "f"-><|"g"->7|>|> How ...
4
votes
2answers
102 views

Usage of StringTemplate

The documentation for StringTemplate has the following example ...