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

learn more… | top users | synonyms (2)

5
votes
3answers
111 views

Elegant way to drop rest of a string at the occurence of a character

For example, I have a string "ahfiehfke$jfwfjejf0". Is there an elegant way to drop all characters after "$"? I know loop ...
2
votes
2answers
165 views
1
vote
3answers
202 views

How can I use functions in file paths?

I'm very new to Mathematica and I'm trying to write into a file. I want to have a function in my file path. For Example: ...
7
votes
5answers
189 views

Generate list of strings from a list of assigned variables

How do I generate a list of strings from a list of assigned variables? Eg. Convert ...
5
votes
1answer
70 views

Handy dates conversion

I feel like something very basic is missing me, $dateformat = {"Year", "Month", "Day", "Hour"}; date = DateString[$dateformat] DateString["Date"] ...
1
vote
1answer
75 views

Is there a way to convert a string to a Table indicator? [closed]

I have a list like this: list = {"k1","k2"} I want to use the elements in the list as Table indicators: ...
1
vote
1answer
45 views

Change parentheses to square-brackets when using CForm

I'm not experienced with Mathematica, but am learning to appreciate its awesome power for manipulations. I get the an expression like this when using CForm (I cut ...
0
votes
1answer
52 views

Dataset fails on StringMatchQ warning due to Missing value

Missing values are a pain mathematically and computationally in general not just in WL, but I think this problem is more related to Dataset handling of warnings: ...
0
votes
1answer
53 views

Creating Function with String Input

I am trying to create a function that needs to transform the input into a string. The objective is transforming a latex input into a calculable mathematica expression. ...
0
votes
2answers
38 views

How do I use DictionaryLookup to exclude words with certain phrases?

I'm looking to use DictionaryLookup to search the English dictionary for words that don't contain certain strings. For example, I want to exclude ...
1
vote
1answer
67 views

Importing Data Issue, Breaking Up Elements

I am trying to import a comma delimited text file as a Table and I am having two issues: First, the file imports all of the numbers that should be separate columns as a single string. This is not ...
10
votes
2answers
126 views

Comparing natural language strings

I have a large spreadsheet with thousands of rows/columns of text. Some are saying essentially the same thing but in different ways. When you enter a natural language question Wolfram Alpha makes a ...
0
votes
1answer
49 views

How to remove unnecessary brackets in one formula

I have some string,like "3+(3*(2+5))", obvious that some brackets are unnecessary. It can write like "3+3*(2+5)", so I try to use Inactive. ...
1
vote
3answers
190 views

How to manage list of list of rules?

Considering we have a list: str = "{1 -> {a -> aa, b -> bb}, 2 -> {2a -> \"{b -> bb}\"}}" Bringing this to expression gives: ...
4
votes
3answers
149 views
0
votes
0answers
35 views

Dealing Repeated pattern in StringReplace

A problem about StringReplace When I'm running into this problem possible [bug] ...
25
votes
7answers
1k views

Splitting words into specific fragments

I am looking into splitting words into a succession of chemical elements symbols, where possible. For example: Titanic = Ti Ta Ni C (titanium, tantalum, nickel, carbon) A word may or may not be ...
1
vote
2answers
47 views

Trouble with ToString and StringForm

The command ToString[StringForm["SomeText=`` as well as OtherText=``.", "textA", "textB"], FormatType -> InputForm] produces the output ...
1
vote
5answers
144 views

How to split list to strings?

Considering a list: lst = {"1", "2", "3", "4", "5", "6"} How can I have two strings : str1 = "1, 2, 3" str2 = "4, 5, 6" ...
1
vote
1answer
97 views

How to fill a Marshal buffer with whitespace using NETLink

Further to Todd Gayley's answer on string handling in a DLL function, I have the following code: ...
3
votes
6answers
1k views

Getting a String from a list of strings

Is there a way to write down Mathematica with a string such as: {"M","a","t","h","e","m","a","t","i","c","a"}?
2
votes
4answers
209 views

How to switch from array to string?

Considering we have an array: a = {2/3, 4/5, 9/7, 3/7, 1/7, 1/9}; How can I get this to be: "2/3 4/5 9/7 3/7 1/7 1/9" ...
0
votes
1answer
87 views

Replace a number in a string

I have several data files I want to import. The names of these files consist of a part that is the same for all of them and a number which identifies them, as in ...
2
votes
1answer
77 views
5
votes
4answers
711 views

A too complicated lookup

I have the following keys: nm = {"bay", "ica", "rat", "tat", "dax", "dow", "sp5", "nas", "mean", "total"}; which I want to use to find a corresponding entry in ...
3
votes
0answers
45 views

Error when combining Except, “*” and an additional character

Anyone knows why StringMatchQ["x", Except[{"1", "2"}]] StringMatchQ["x", Except[{"*"}]] StringMatchQ["x", {"1", "*"}] (* without Except *) all work as ...
30
votes
2answers
662 views

String-manipulation bugs in v10.1

Fixed as of 2015-04-06 via paclet update. The new version 10.1 has introduced some strange (possibly buggy) behaviour compared to v10.0: ...
1
vote
2answers
74 views
2
votes
5answers
76 views

How to convert string to integer list?

Saying we have a string: "1 2 3 4 5 6" I want to convert this to integer list. First I do: ...
5
votes
5answers
277 views

How do I pad numbers to the left so that all are the same length?

I have a list of numbers like {-6, 1, 3, 23} and want to get a list of strings, all of the same length, with zeros padding on the left as needed, like ...
2
votes
3answers
115 views

How to delete a pattern from String?

Having a string like : "{Aaaa -> a, Bbbb- > b, Cccc -> , Ddddd -> c, Eeeee -> , Fffff -> e}" I want to delete the parts that contain ...
14
votes
2answers
195 views

Bug in Operator Form of StringCases

fixed in 10.1 (windows) According to the documentation there's an operator form for StringCases ?StringCases Here is the ...
3
votes
2answers
226 views

Explicit asterisk or @ sign in string patterns

What string pattern will match an explicit asterisk (*) or at-sign (@)? The obvious example, StringMatchQ["*", "\*"], returns ...
13
votes
7answers
763 views

How to sort digits in a string while keeping other characters untouched?

Now there is a string with digits and letters, for instance, "95uge678r3gi89hgfe30kgh063d51". And the expected output is ...
0
votes
2answers
45 views

SequenceAlignment behavior

When I do: SequenceAlignment["-0.999995756767227832383453368554576431549","-0.999995756767227832383346049698547342279"] I get: ...
12
votes
3answers
683 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. ...
5
votes
1answer
174 views

Extra spaces when exporting strings into pdf (bug, linux)

Rationale: Imagine you would like to create a publication quality figure in Mathematica, from under Linux. Naturally, it will contain text/labels. Problem: Here is a simple string ...
24
votes
6answers
730 views

Partition string into chunks

This seems like it should be trivial, but how do I partition a string into length n substrings? I can of course write something like ...
29
votes
4answers
3k views

Looking for “Longest Common Substring” solution

I'm looking for robust code to solve the "Longest Common Substring" problem: Find the longest string (or strings) that is a substring (or are substrings) of two or more strings. I can just code it ...
13
votes
3answers
672 views

How to remove accents from text?

I would like to know how I can remove accents from a string. For example, how can I transform "string test áéíóú" into ...
0
votes
1answer
46 views

How to check String format?

How can I check if the string contains a real or integer number, space and string? e.g. StrCheck["156 af"] = true ...
11
votes
1answer
392 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
1answer
42 views

How to manipulate string parts?

Let's consider I have following string: "{a-> POR, b-> D610, c-> 0, d-> \"300/7\", e -> \"1/400\"}" How can I run over and update anything that is ...
19
votes
1answer
409 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 ...
0
votes
1answer
144 views

Converting strings of the form “1.34e5” to real numbers? [duplicate]

ToExpresssion doesn't understand real numbers of the form "1.34e5". How do I convert the string ...
2
votes
1answer
99 views

How do I dynamically construct a string from a variable number of 'PopupMenu's in 'Manipulate'?

I have a string with a variable length, determined by the value of a SetterBar and whose characters are determined by a corresponding number of ...
14
votes
8answers
900 views

DeleteCases on list of Strings

Consider the following: data={"AB","CD","AF"}; Now I would like to delete all String from data which starts with "A". ...
11
votes
3answers
703 views

Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
0
votes
1answer
32 views

Selecting from a list [duplicate]

OK, I know this must be a simple problem, but right now I'm just stuck and need some advice with this :). I have the following list: ...