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

learn more… | top users | synonyms (4)

3
votes
1answer
43 views

`ReadString` and `StreamPosition` behaving strangely with custom terminators

I've stumbled on a strange behavior while trying to use custom terminators for ReadString. When I use a simple String as the ...
1
vote
0answers
68 views

Using \n (new line) as delimiter in StringSplit

While trying to build my own simple C-language highlighter for strings in Mathematica (see here for a very sophisticated highlighter generator package by Leonid Shifrin) I came upon the issue of using ...
21
votes
3answers
805 views

Typoglycemia text manipulation

I was just reading the article: https://en.wikipedia.org/wiki/Typoglycemia "... readers can understand the meaning of words in a sentence even when the interior letters of each word are scrambled ..."...
1
vote
0answers
48 views

Creating an indexed set of functions with the indices in the function names [duplicate]

As the titles describes, I want to create a list of functions like the following, where the indices are not in the argument slots: ...
12
votes
0answers
121 views

Can Mathematica convert a RegularExpression into a StringExpression or vice-versa?

I know that Mathematica can perform string comparison using either StringExpression or RegularExpression. Although regular ...
15
votes
2answers
193 views

Unexpected behaviour when pattern matching with Longest

I came across some unexpected behaviour today when using the Longest function when trying to do some pattern matching. ...
0
votes
1answer
49 views

Mapping StringToDouble over nested lists of strings, still confused about slots

This is a simple question about slots but I still cant see how to do it after searching stackexchange. (I'm importing a large data file as text and to convert to numbers I think it'll be quicker to ...
16
votes
5answers
652 views

Opposite of StringSplit

What is an appropriate command that does the opposite of the following? StringSplit["a b c d e f g"," "]
4
votes
1answer
107 views

Trim a list of elements [closed]

I suppose this is a trivial question to many of you, please bear with me. I have a long list of words, list1. I would like to "remove all words that contain a specific letter, say "o". ...
0
votes
1answer
44 views

Convert string to function with an argument

I am trying to build an expression by first writing it out as a string and then using ToExpression to convert it to an expression. However, I cannot figure out how to make expression recognize x as an ...
1
vote
1answer
62 views

How to use StringReplace “from bottom to global”?

Suppose I have an original string that looks like: str1 = "erewrer<.rer>r33e<erer>re<><>rer\nrer<ew212>" I want to get rid of all ...
6
votes
2answers
248 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 ...
4
votes
3answers
174 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 ...
0
votes
1answer
50 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
1
vote
1answer
78 views

How to get missing lines from a file? [closed]

Let's say I have this file dat.csv which basically is a number of strings like that: animal horse duck dog plant tree grass sunflower sky oxygen nytrogen air ...
3
votes
1answer
172 views

How do I use StringReplace to replace repeated characters?

Suppose I have str = "dededekmkmkmvkfjdedemkvmlvdedekfmmdedededemkmkde" And I want to replace the repeated "de"s to one and produce (in a real example, the "de"...
4
votes
1answer
39 views

help with string patterns and RemoveCellTags

I am building a table of contents using AuthorTools. I used it to create cell tags so the TOC can make hyperlinks, but then I decided I wanted to change them. But I am having trouble removing the ...
0
votes
1answer
74 views

How to convert this .txt data into a list of points [closed]

Question How to import data from a .txt file into Mathematica and convert it to an expression? Download the .txt file here (click download): http://pastebin.com/2NW2DfiE
2
votes
1answer
49 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 ...
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 ...
4
votes
2answers
66 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
79 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 ...
5
votes
3answers
188 views

Can StringTemplate be extended to offer printf-like formatting capabilities?

Apparently, Mathematica has no real sprintf-equivalent (unlike any other high-level language known to man). This has been asked before, but I'm wondering if the new ...
5
votes
1answer
153 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? ...
3
votes
1answer
64 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 ...
15
votes
3answers
428 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, ...
1
vote
2answers
91 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: ...
2
votes
2answers
60 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 ...
6
votes
1answer
146 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 ...
21
votes
8answers
4k views

How to express an integer number in English words?

How do I convert a number to a readable string? I would like to implement a function, inWords[], inWords[n_]:= ? which ...
4
votes
2answers
97 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 ...
3
votes
1answer
81 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
0answers
296 views

Negative power instead of fraction [duplicate]

Solve returns a solution in the form {{ x -> y / a^2 + y^2 / a^7 }}. Since I want to process the input (with another program) in terms of Laurent polynomials, I ...
3
votes
1answer
89 views

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

For the string ((!@#)), the shortest match for the pattern "("~~__~~")" should be "(!@#)", ...
8
votes
1answer
142 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 ...
0
votes
3answers
98 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 ...
2
votes
0answers
129 views

Read in bezier curve from svg file

I am trying to do some calculation of some svg file,After read in with Import["filename","XML"]and some easy operation, I can get the string of the bezier curve, ...
0
votes
3answers
81 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? ...
3
votes
1answer
42 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
1answer
79 views

Stringifying $GeoLocation for the browser

Currently, when I ask for ExportString[{"geoLocation"->TextString[$GeoLocation]},"JSON", "Compact"->True] I get this: ...
6
votes
1answer
126 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
84 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 ...
20
votes
4answers
423 views

Unexpected result {“.a”, “co”, “.m”} from Sort[{“.m”, “.a”, “co”}]

I came across the following situation: Evaluating Sort[{".m", ".a", "co"}] Results in {".a", "co", ".m"} I wondering: ...
3
votes
6answers
263 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 ...
0
votes
0answers
32 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 ...
10
votes
5answers
249 views

Backquote in string template?

I need to have backquotes in a StringTemplate. For example StringTemplate["``1``"][2] Returns ...
1
vote
1answer
61 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
35 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
70 views

How to change the word's color in string

The picture I load is my target: This is my code in mathematica ...