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

learn more… | top users | synonyms (2)

2
votes
1answer
229 views

Change values in string under condition

how to change the width and height in the HTML code into some other values decided by ratio and a fixed width? The background is that you can adjust a image in ...
4
votes
4answers
200 views

How to construct tuples with a given order?

How do I create a list of tuples with an ordering imposed on them, where each element is from a generating set? Specifically, I'm trying to create a listing of tuples $(x_1, x_2, ..., x_n)$ such that ...
5
votes
2answers
229 views

Removing commented lines of text in a string

Suppose that I have a string str. str contains headings -- which are written in commented lines -- and data. For example: ...
3
votes
1answer
450 views

Convert String to List of Numbers

I want to create a function that when a string is entered it will turn it into a list of numbers, these numbers are the numerical form of the characters in the string. e.g. a=1, b=2, c=3, d=4 and ...
-3
votes
2answers
130 views

StringCases functionality

I have a list of strings in where each element of the list is in this form: ...
16
votes
1answer
308 views

How to strip all formatting from a string and convert it to plain text?

The documentation on String states: But if I try to perform some manipulations on this string, for example, take 2 words from the left, I get some shards of ...
2
votes
2answers
111 views

StringCases functionality on a varying rows of data

There is a string in this form: ...
1
vote
1answer
158 views

Style markers in strings

I'm dealing with strings in Mathematica and I would love to handle their stylling in the most cenvenient way. Without loss of generality, let's assume I want to make some parts of string ...
4
votes
3answers
319 views

Using subscript in a string

I am trying to create a string of the form $0 < d_1 < d_2 < \ldots < d_n$ For a given n. My closest attempt so far is ...
5
votes
2answers
179 views

Extract substring by repeated StringPattern

This code failed, but may exemplify my intention. StringCases["aA1bbbbbbbbbbaA2baA3b...aA4b",Repeated[Shortest["a"~~xx__~~"b"],{2,100}]] I want to get the ...
1
vote
1answer
89 views

How to make the StringExpression not occur in my case?

Why is there a StringExpression in the following code? ...
19
votes
7answers
1k views

Elegant and fast way to join all string sequences

I want to do what title says: {"a","b",1,2,3,4,"a",2,2,2,"edg","?"} => {"ab",1,2,3,4,"a",2,2,2,"edg?"} in the most elegant way. For example one replacement rule for ...
2
votes
1answer
682 views

How to import a Microsoft Word document into Mathematica?

I have a Microsoft Word document in DOCX format. I need to import it into Mathematica as a String preserving all formatting (font, size, bold/italic style, colors, ...
1
vote
3answers
316 views

Replace with position and order number

question conversion1 : Convert "[AA]AB[AA]BB[AA]B[AA]CCC" to "[A1A2]A3B1[A4A5]B2B3[A6A7]B4[A8A9]CCC" conversion2 : Convert ...
8
votes
0answers
198 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 ...
3
votes
2answers
248 views

StringReplace except some pattern

StringReplace and search out of one pattern ...
1
vote
0answers
100 views

Split one string about a fixed width with `SyntaxQ=True`

How to split one string about a fixed width, the string may come from the input or output cell of Notebook. sample string ...
13
votes
2answers
457 views

How to embed an image into a string?

Note: The bug described in the post is in Mathematica 9, and has been fixed in 10.0. The documentation for String contains the following statements: Strings ...
1
vote
1answer
125 views
18
votes
3answers
346 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: ...
6
votes
1answer
268 views

String pattern search and replacement — it works, but produces error messages only the first time it is called

I defined a function in Mathematica to process a pre-generated string. More specifically, I'd like to process some parts of C codes generated from MMA. Basically what my function does is to expand the ...
1
vote
1answer
147 views

Searching a string that may contain Null

I have an array of triplets that can be approximated by the following code: ...
6
votes
1answer
216 views

Match sequence of zero or more characters except a given character

This looks like it should be simple: I want to match an "i" followed by an "o" with an arbitrary (possibly zero-length) sequence of characters in between, unless that sequence also contains an "i". ...
3
votes
1answer
152 views

Importing strings in Mathematica

This is my first post so apologies if any obvious mistakes. I'm trying to work on a data containing names (in quotes) in Mathematica. The data is already saved on my system under ...
2
votes
1answer
203 views

Showing special characters in text containing unicode

How does one conveniently convert a string like: "Ya no me burlar\:00e9 de la diabetes de Nick Jonas. Me lo guardar\:00e9 para cuando le corten la pierna. S\:00ed es que a\:00fan alguien lo recuerda, ...
5
votes
6answers
262 views

Selective thinning of string elements in nested lists

I have a nested list similar to this example list (but much bigger and more messy): ...
2
votes
1answer
179 views

Explicit asterisk or @ sign in string patterns

What string pattern will match an explicit asterisk (*) or at-sign (@)? The obvious example, StringMatchQ["*", "\*"], returns ...
3
votes
1answer
195 views

How to extend dictionary.txt

How to extend the default dictionary.txt for Dictionarylookup to all words? For example, first I ...
31
votes
1answer
527 views

Why is StringExpression faster than RegularExpression?

Edit: as noted by Albert Retey the performance difference is only seen when sub expression extraction is performed. If this test is used below the timings are similar: ...
4
votes
5answers
272 views

A simple StringCases problem

Given this text: text1 = " A Vitamin D Deficiency (ICD-9-CM 268.9) (ICD-9-CM 268.9) 09/11/2015 01 "; Yes, the ICD code values are duplicates- possibly but ...
5
votes
3answers
349 views

Find the position of a string element, knowing only part of the string

I have a list, e.g.: list = {1, 2, 3, "Element 1", 4, 5, "Element 2", "Something else 1", "etcetera"} Now, I want all elements starting with ...
6
votes
1answer
113 views

How does `LongestCommonSubsequence` work?

When I recently came across this posting about LongestCommonSubsequence I was curious about how the function worked. ...
3
votes
1answer
273 views

String replacement to make the TeXForm output beautiful

This question is inspired by this question: How to convert the symbol $d$ in Integrate into $\mathrm{d}$?. Although it’s not a big problem, the TeXForm can be ...
0
votes
0answers
97 views

How to highlight a string pattern? [duplicate]

This is an example in the help pages (Working with patterns: Highlight Patterns): ...
10
votes
1answer
648 views

Mathematica equivalent of regex '\w{2,3}'

It beats me to write the Mathematica pattern equivalent to the regex: \w{2,3} Any ideas?
2
votes
2answers
174 views

Image processing - How can I apply an operation to several images at once?

I imported pictures into Mathematica, and used names for them that follow the easy scheme "name" string joined with an integer, ranging from 14 to 20. Printing these images on screen works nicely: ...
0
votes
2answers
117 views

help with StringJoin [duplicate]

dollarWon := 100 "(" <> Style["$" <> ToString[dollarWon], If[dollarWon >= 0, Darker[Green], Red]] <> ")" I am getting an error: String ...
5
votes
2answers
181 views

How to count words in a Greek text

I want to perform a simple analysis of some Greek text: collect the different words used and count their frequency. It seems that some of the built-in commands do not work well with Greek letters. For ...
1
vote
2answers
156 views

How to convert TableForm to proper LaTex and why is “\” not replaced by StringReplace?

I'm trying to optimize the teXForm output of a table because the standard output ist not satisfying: ...
11
votes
2answers
281 views

Transform fancy usage messages in 1D string

When we look at the usage messages of built-in functions nowadays (not in the good old times, when they were a simple descriptions) we see that although they look pretty in the front end, it is really ...
3
votes
2answers
386 views
7
votes
3answers
297 views

Unencoding encoded URLs in a function

Is there a built-in function for decoding encoded URLs in Mathematica? I would like to convert an encoded URL, for example ...
14
votes
2answers
311 views

Haiku Extractor

Inspired by the cool Tumblr Haiku Times that searches for accidental haiku in New York Times articles, I tried my hand at implementing such a search in Mathematica for my own text samples. I'm still ...
1
vote
2answers
124 views

Finding strings in Web Code [duplicate]

I haven't found an answer that solves my problem, although I think it's actually a simple one. It seems hard to me because I don't have a lot of experience with string patterns. I have a Web Code ...
0
votes
1answer
207 views

Construct file names using a number and a string prefix [duplicate]

I'm trying to append filenames with Mathematica, and cannot do it. The output of my calculation are two lists : X and Y, ...
-4
votes
2answers
205 views

how can i convert data into string format? [duplicate]

I have nested-lists in number format,like data={{1,2,3},{2,{3,4,50}},{4,5,6},{3,{3,{5,6}}}} I want to convert each number into ...
5
votes
1answer
158 views

Extracting text from cells, preserving non-ASCII characters

Consider the following setup, based on this answer by WReach: ...
2
votes
2answers
2k views

Faster way to convert real strings into numbers [duplicate]

Working with big files, I have to convert some numbers that are in string format into real MMA numbers. I know that I can use ToExpression but it's slow when ...
1
vote
2answers
119 views

Why do I get two different results from StringLength?

I spent a reasonable amount of time to find the origin of an error in a larger code segment. ...
0
votes
3answers
416 views

How to export a header before the data in the result file?

I would like to export a phrase to my result data as a heading. I'm exporting the data correctly with Export["file.dat", table]. But I'm doing several ...