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

learn more… | top users | synonyms (2)

5
votes
2answers
128 views

How to Clear variables represented as a list of strings?

Say I have a string list called fullpara fullpara={"width", "long", "line", "distance"} And there are corresponding variables ...
7
votes
5answers
230 views

String replacement question

If you have a string string="<ALK>ene" and I have a list alk={"meth", "eth", "prop", "but", "pent"}, what function ...
3
votes
2answers
121 views

String pattern matching & replacement

I would like to find all occurrences of a full stop "." followed by a capital letter in a string and have these replaced with a "; ". How do I do this in Mathematica? e.g. ...
3
votes
0answers
73 views

Copy string with markup so it looks good on input

How can I copy a string with a bunch of *Box expressions without it blowing up into the raw expression? ...
5
votes
4answers
262 views

Is there a more Mathematica-y way to label these plots?

I am studying an infinite square well in the context of quantum mechanics. ...
1
vote
0answers
29 views

How can I convert a matrix into matlab form string? [duplicate]

How can I convert a matrix into matlab form? ...
3
votes
2answers
110 views

Mathematica regex equvalent of \l

In normal RegEx \l will make the character to the right lowercase. However, it seems like the RegEx in Mathematica does not have this functionality. For example ...
0
votes
0answers
28 views

Sorting String Date in Asceding Order [duplicate]

How do I order string dates (month/year format) in ascending order, e.g., from 11/2011 to 07/2012: 02/2012 04/2012 07/2011 08/2013 08/2011
2
votes
1answer
82 views

Make MyLogicalExpand

The function by Mathematica to expand a formulation with ANDS, ORS, NOT, XOR, and others, is LogicalExpand, let see an example: ...
3
votes
1answer
157 views

Extract date from a not well-formed string

Is there a way to robustly extract date and time from a text? Say for example: ...The event will be held on 17/10/2013 at 3:30 PM in the room 121 and everyone is welcome... should return: ...
12
votes
4answers
462 views

How do you get a list of filenames from a URL?

How would I get a list of filenames available at a URL? For example, list the files at: http://www1.ncdc.noaa.gov/pub/data/cmb/drought/weekly-palmers/2005/
2
votes
1answer
109 views

Elegant transformation of various rules to strings, {f[z_] -> y} becomes “f = @(z) y”

Assume that I have some function for transformation mathematica expressions to strings. For simplicity, just assume it is an identity: ...
4
votes
2answers
245 views
12
votes
5answers
465 views

How to remove duplicate characters from a string?

How do you remove duplicate characters in a string without converting the string to a list. I want to delete all duplicate characters in a string (i.e. get the unsorted union of characters). For ...
1
vote
1answer
79 views

Insert glyphs into a string using functional code

I asked this question few days ago: Replace For-loop with functional code Suppose I use strings instead of lists; for example a = ToString /@ {123123, 112233};` ...
9
votes
1answer
118 views

Named string patterns in Alternatives, why does it depend on order?

When using the same name for part of patterns inside Alternatives how come it behaves differently for strings than in normal patterns? ...
5
votes
2answers
185 views

How to get complement of a pattern

I have a list. I want to get all the elements in that list which do not match a given pattern. That is, I want the strings which do not match any of the following patterns: First and last characters ...
3
votes
1answer
70 views

Use of StringExpression as argument

Is it possible to use a StringExpression as a pattern for an argument? I.E. something like foo[chars__~~ WordCharacter.. ~~ num:NumberString] := {chars, num}; At ...
5
votes
3answers
220 views

How can I find English words among the names of the characters in the Mathematica character set?

I want to find some single meaningful words in the "ASCII/Unicode" form characters. For example, I want to get alpha from ...
4
votes
0answers
58 views

Error with String patterns producing Removed[“$$Failure”]

While working on How to capitalize the first letter of each word in a string and trying to understand why certain characters were not considered letters I tried this: ...
7
votes
3answers
351 views

How to capitalize the first letter of each word in a string

The following examples only work for the first character of the whole string, but not of words. ...
2
votes
1answer
203 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 ...
3
votes
4answers
170 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
173 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: ...
2
votes
1answer
209 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
111 views

StringCases functionality

I have a list of strings in where each element of the list is in this form: ...
15
votes
1answer
223 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
98 views

StringCases functionality on a varying rows of data

There is a string in this form: ...
1
vote
1answer
119 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 ...
1
vote
2answers
89 views

String pattern with symbols [closed]

I have got a huge list with elements like this: {":"ofa-legacy-conference",", ":"obama-2012",", ":"ofa-states","} The first element is ...
3
votes
3answers
159 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
152 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
73 views

How to make the StringExpression not occur in my case?

Why is there a StringExpression in the following code? ...
18
votes
7answers
907 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
392 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
251 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 ...
6
votes
0answers
114 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
200 views

StringReplace except some pattern

StringReplace and search out of one pattern ...
1
vote
0answers
88 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
346 views

How to embed an image into a string?

The documentation for String contains the following statements: Strings can contain any sequence of ordinary and special characters: … Strings preserve ...
1
vote
1answer
86 views
17
votes
3answers
328 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
208 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
115 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
181 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
129 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
162 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
172 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
139 views

Explicit asterisk or @ sign in string patterns

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

How to extend dictionary.txt

How to extend the default dictionary.txt for Dictionarylookup to all words? For example, first I ...