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

learn more… | top users | synonyms (4)

2
votes
1answer
36 views

read Python-generated data file

I've read similar-but-not-quite-the-same questions : I have to read a python-generated data file which contains complex numbers. So, the numbers appear as (real+imag j). And of course Mathematica ...
3
votes
2answers
56 views

Abbreviated expressions in StringCases? [duplicate]

Am I missing something here? There's no support for abbreviated expressions in StringCases? StringMatchQ["MATCH", "*H"] (* ...
5
votes
1answer
68 views

What are “\<” and “\>” delimiters in box expressions?

If I enter a string (say, "abc") in a cell, and then switch to box representation (Shift+Ctrl+E or menu item ...
6
votes
2answers
210 views

How to I extract the element name of a chemical compound in a string?

Say I have a compound Fe3O4, and I want to separate the name of elements and number. The code I write for separate number is ...
1
vote
1answer
31 views

Oddity with ToExpression [duplicate]

Is this a bug? ToExpression["3231.432"] 3231.43 I would have expected the following: 3231.432 I am using Mathematica 10.2.0
3
votes
1answer
59 views

How to collect elements in one list with the constraints provided in a second list

I wish to collect the items in the first list provided the constraints in the second list. For example in the lists shown below the first list shows a bunch of strings and the second list shows the ...
2
votes
2answers
48 views

Remove an element of a list [duplicate]

I want to check if any element of a list contains Missing["NotAvailable"] If so I want to delete the entire list. If I am correct I need to have some ...
1
vote
2answers
80 views

Void elements / self closing tags export to HTML

There are some built in rules in exporting that automatically create Void elements / self closing tags for some tags: ...
6
votes
1answer
128 views

String replacement in a large text file

I have to replace a string, let's say "ABC" to "XYZ", in a huge plain text file (10 Gb and above). Obviously, the ...
3
votes
1answer
68 views

Wrapping long strings at word breaks

My code (PostScriptForm) returns a long string, about 7k characters, in which there are eight deliberate “\r\n” ‘paragraph’ breaks. Copying the long string into a ...
3
votes
2answers
156 views

Replacing doubled letter with that letter plus a code

I want to replace the second occurrence of a letter in a double letter pair with a specified code. For example, if the code is a capital letter "X", then the input ...
3
votes
1answer
81 views

How to use `Shortest` for pattern matching? [duplicate]

For the string ((!@#)), the shortest match for the pattern "("~~__~~")" should be "(!@#)", ...
7
votes
1answer
131 views

How to take all sub-strings in a string that are combinations of specified characters only

"tgtaaaaacaagaaaaacatggaatgtataatactataaataaaaaaagtaggaagaagaaccaaaaca\ aagggcgttttaaagagagacgaat" based on the above string (a DNA sequence) I wish to extract ...
3
votes
1answer
27 views

Entering null characters in a string

This question is about parsing files that contain nulls (character code zero) as field separators. Intending to attempt to answer this I began by trying to enter a string containing a null, e.g. by ...
0
votes
3answers
63 views

Importing Text file with Null Character column separation

I have a text file (ANSI econding) with two columns of real numbers separated, unfortunately, by a "Null Character" ("\.00"). How can I import this data easily? ...
0
votes
3answers
89 views

Parsing, StringReplace and token priority

Although I was slightly taken aback when I came across the behaviour, the following examples are perfectly in line with the way StringReplace is described in the ...
6
votes
4answers
593 views

How to replace a space by a comma

in this expression = "{1 2 3 4 5 6 7 8}", I want to replace each space by a comma , to get ...
6
votes
1answer
123 views

Finding quotations in a text

I actually deal with the problem of finding quotations (i.e. "this is a quotation") in larger texts of different languages, mostly German and English. Unfortunately there are several ways to fill text ...
3
votes
5answers
80 views

Insert or Remove randomly

I have a series of characters such as "ABCVABVCCAVB". I wish to randomly remove or insert character. I could make to remove case like deleting all A, or B,... but I wish to remove or insert only 1 ...
0
votes
0answers
31 views

Printing the name of variable in a list as a string [duplicate]

I have a list of objects MyList = {OII,IOI,OIO} where every object is a vector (the names are for ease of use, since they stand for 011, 101, 010). For example ...
3
votes
6answers
253 views

Joining strings in every third element in a list

How do I join a string to the first and every third element in the list? Example: list={1,2,3,4,5,6,7,8,9..} ={"string1",2,3,"string4",5,6,"string7",8,9..} I ...
10
votes
5answers
226 views

Backquote in string template?

I need to have backquotes in a StringTemplate. For example StringTemplate["``1``"][2] Returns ...
1
vote
1answer
39 views

How to add a `Style` string or `Hyperlink` in CloudDeploy?

There are two wrong code like this: The first problem is I want to put the red string to Title. ...
2
votes
1answer
31 views

Evaluation of BlankNullSequence inside StringReplace

I would like to replace the occurrence of "a(x)" and "b(x)" in a list with "a(x-na)" and ...
3
votes
1answer
61 views

How to change the word's color in string

The picture I load is my target: This is my code in mathematica ...
4
votes
2answers
94 views

Unescape Formatting in Strings [closed]

Mathematica has a dirty habit of sometimes escaping all the formatting in my strings when loading a .nb. I know this is inevitable for ...
1
vote
0answers
45 views

String Question [closed]

Consider: listOfScores = Import["http://www.handsonstart.com/ExampleDataScores.txt", "Data"] Which gives this output: ...
5
votes
1answer
118 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
36 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
42 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
56 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
121 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
40 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
61 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
419 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, ...
2
votes
2answers
79 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
331 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
82 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
42 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
53 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
123 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
54 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
159 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
92 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
80 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
53 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
33 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
49 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
284 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 ...