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

learn more… | top users | synonyms (4)

0
votes
1answer
45 views

insert comma between numbers

I have the following numbers rows and I want to insert a comma between the numbers? 6 7 9 51 64 68 79 102 116 128 148 155 184 202 273 283 292 1 7 8 10 52 65 69 80 103 117 129 149 ...
0
votes
0answers
40 views

Testing if a character is a whitespace [closed]

Is it possible to define a function which returns true if its only argument is a whitespace character (space, tab, newline, ecc...), false otherwise? I tried with various testing functions on the ...
6
votes
4answers
164 views

Searching a phrase in all *.nb files

I have so many *.nb files in a folder. In one of them I have written a phrase, unfortunately I cannot remember that file. I am searching about it and the file in ...
3
votes
2answers
105 views

Replace non-zero elements with symbol

I have a very large matrix (tensor) in Mathematica with some zero and non-zero elements. I am interested in replacing the non-zero elements with some symbol or a 1 so that it is easier to view the ...
8
votes
1answer
121 views

What kind of pattern should I use with StringCases?

Consider the string str = "ABCaDEFbcABCdefDEF" I'd like to take out all substrings surrounded by the substrings "ABC" and ...
2
votes
3answers
144 views

What is an efficient way to pick out consecutive, same first-letter words from a list?

Taking a list of words, I'd like to pick out consecutive words that start with the same letter. The output should be a list of these pairs. The following is relatively slow: ...
12
votes
1answer
516 views

How to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?

I have an opened Mathematica notebook containing several cells. Suppose, I am interested in one of them -- it may contain a complete or incomplete expression (e.g. with syntax errors, highlighted ...
0
votes
0answers
19 views

strse error in string operation

When I using jSoupLink, I found strange behaviour First, I load jSoupLink and define linkList ...
2
votes
1answer
53 views

Why is head evaluation inconsistent in pattern replacement?

I noticed the following unexpected result: In[90]:= "foo" /. x_String -> Head[x] Out[90]= Symbol Why is it that Head[x] ...
1
vote
0answers
72 views

Numbers not treated as numbers

I'm apologize for the stupidity of this question, but I've run out of ideas. I have some data saved in a mx file. When imported, MM isn't treating the values as numbers. For instance: ...
12
votes
1answer
208 views

Longest common substring for multiple strings?

I'm looking for a way to get the longest common substring for multiple strings such as {home/dir1/dir2/jmoasd.txt,home/dir1/dir2/ivbnoxcihv.txt,home/dir1/dir2/siuhgiuchv.txt} should yield ...
3
votes
3answers
228 views

How to switch between a binary number as String and a as a list of digits?

I was trying with String Functions and I viewing any posts and have no results I want to know 1.- From cromo33 = Table[RandomInteger[], {i, 1, 33}] cromo33 ...
3
votes
3answers
97 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 ...
6
votes
3answers
307 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
40 views

StringSplit acting weird on a String in StandardForm [closed]

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 ...
2
votes
2answers
67 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
1answer
87 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
78 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 ...
0
votes
0answers
45 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 ...
6
votes
1answer
102 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
268 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
335 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
569 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
106 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
109 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, ...
11
votes
2answers
303 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
878 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
207 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
56 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
64 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
40 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
65 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
804 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
119 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
190 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
646 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
43 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
245 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