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

learn more… | top users | synonyms (4)

6
votes
3answers
283 views

How to convert a string into a structured list

I am trying to use an efficient notation for the timing of sounds that i can play in Mathematica. I would like to parse the string "{ab{c{de}}f}" as the list ...
2
votes
0answers
38 views

StringSplit acting weird on a String in StandardForm [on hold]

To begin, this is my first post on stack exchange, so if my question is not up to par please let me know so I can make the appropriate edits. Now for my question: why is it that parsing a string in ...
1
vote
1answer
51 views

Extract every nth character from a string

I'm trying to extract every 21st character from this text, s (given below), to create new strings of all 1st characters, 2nd characters, etc. I have already separated the long string into substrings ...
2
votes
2answers
54 views

How to translate/convert UTF-16 code to its corresponding word/characters by Mathematica?

I'm using Mathematica10.0.2 on my Win7. Recently I crawled some websites by mathematica and within the information returned by URLFetch there are plenty of UTF-16M codes. These UTF-16M codes are ...
-6
votes
0answers
53 views

rename files randomly

I need to read a directory with pdf files, rename them by numerical sequence of 8 digits when lifting with pdf extension, and then record the result (the idea is that they are totally random names ...
6
votes
1answer
84 views

How to make captions for a movie?

I'm trying to make my own video parody with custom subtitles. Creating your own custom subtitles file in a text editor with the SubRip or .SRT format is easy to do, it looks like this: Where ...
4
votes
1answer
76 views

Extracting integers from a string

Imagine I have a block of text that contains words and numbers. I want to extract all the integers from the text. Thus, if the input is ...
-1
votes
0answers
81 views

Problem with System.Array in Mathematica

i am using NETLink to use some COM Objects in Mathematica, it works fine with almost all the functions, except one, that function has the following sintax in VB: Compute_CurrentPlan(nmsg As Long, ...
0
votes
0answers
42 views

Constant Strings?

I am writing a workbook to compute double integrals, and in order to graph the function in polar/cylindrical form, I have to make a substitution in the original formula. How can I have the original ...
5
votes
1answer
98 views

StringPattern to remove markers around text

I am not able to figure the StringPattern to use to remove markers in string. This is the input. ...
10
votes
4answers
263 views

Convert elements of list to string

how easily can I convert elements of this list to string. If I have output like this: {{M, 1, 0, 0, 1, 1, 1, 0}, {A, 0, 0, 0}} And I want something like this: ...
12
votes
4answers
332 views

balanced Shortest[] and string-patterns

The pattern Shortest["A"~~__~~"B"] is oriented : It assumes the text is read from left to right and it takes the text between the first "A" and the next "B". Any ...
8
votes
3answers
559 views

Finding all sublists or substrings of a given list/string

Given a list or string, how do I get a list of all (contiguous) sublists/substrings? The order is not important. Example for lists: ...
2
votes
1answer
105 views

Problem with deleting words from text [closed]

The task I need to do is to import a text book from here http://www.gutenberg.org/cache/epub/36/pg36.txt, then drop the last 20000 words from it and determine how many times the remaining words occur. ...
2
votes
3answers
89 views

Importing a VCF file with quoted-printable encoding

The documentation has an example importing a VCF address book file which works fine: Import[ "ExampleData/wolfram.vcf" ] {{FormattedName->Wolfram Research, ...
10
votes
2answers
300 views

How can one represent a string pattern with prohibited substrings?

Say I have the following string: "<hello>something WRONG</hello><hello>something else</hello>" I am trying to find code that works like the ...
4
votes
1answer
129 views

Insert a symbol include first and last position [closed]

Assume we have a list list = {"a", "b", "c", "d", "e", "f"} Then use this code: StringRiffle[list,"*"] But ...
5
votes
3answers
860 views

Analyzing frequency of individual letters in a large body of text

There are interesting histograms about the English language: BarChart[Counts[StringTake[WordList[], 1]], ChartLabels -> Automatic] ...
1
vote
3answers
66 views

Adding numbers to a list

Say you have the following list of 12 elements X={"x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x"} And I want to turn it into the following sorted ...
5
votes
1answer
66 views
5
votes
5answers
205 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 ...
3
votes
2answers
55 views

How would I split a string into substrings ending with a delimiter and a maximum length?

I have a list of parameters, formatted as a string of integers and reals in both simple and scientific notation, with a comma as delimiter. A short sample: ...
0
votes
1answer
33 views

Extra character in StringJoin [duplicate]

When I was trying to join a URL with a parameter and execute it with URLFetch, something unexpected happened. Here is the code (The URL below doesn't exist and is ...
-1
votes
2answers
62 views

Matching timestamped data

I bet this question is a gimme for most of you guys, but I'm having a bit o' trouble figuring it out. Thanks ahead of time for your input and help. Soooo, I have two datasets where column 1 is a ...
4
votes
5answers
125 views

How to efficiently stream words and whitespace from a large text file

I want to tokenize a large (~20 MB) file, opening it and streaming the words, but preserving the whitespace as well. Example: ...
3
votes
1answer
37 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
55 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
800 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
115 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 ...
13
votes
2answers
164 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
45 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
622 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
41 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
239 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
173 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
77 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
163 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 ...
4
votes
1answer
38 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
73 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
45 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
137 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
64 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
76 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
180 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
141 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? ...