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

learn more… | top users | synonyms (2)

5
votes
4answers
90 views

String matching balanced pairs of braces

I am trying to extract from a string in Mathematica all instances of \newcommand{ABC}{DEF} Where ABC and ...
-1
votes
0answers
24 views

How to compare strings insensitive? [on hold]

To compare str1 with str2 I would do StringMatchQ[str1, str2] What if I want the ...
1
vote
1answer
73 views

How can I convert a fraction to a string that can be used in a file name?

I want add an index to the file names of my exported images, so I'm using ToString. But I have a problem when my index is a fraction, because then the generated ...
1
vote
1answer
37 views

Remove line breaks or return codes from string

I have imported string data, which appears to have line breaks or return codes in it invisible in a notebook input cell. Copying a string and pasting into Apple Pages with control codes showing gets ...
10
votes
3answers
350 views

Modifying strings in a list efficiently

I have a list of strings $\{s_1,s_2,\ldots,s_n\}$. I would like to to produce the following list of strings: $$ \{s_1<>1,\ 1<>s_2<>1,\ldots,\ 1<>s_n\} $$ In other words, I want ...
0
votes
0answers
38 views

Recurrence relation for multivariate polynomials

I am trying to define a function which recursively computes a polynomial associated to every binary string: ComputePoly[s_]:=(** Recurse on the string s**) For ...
2
votes
3answers
149 views

How to extract numeric value?

Considering two situations: I have a string "F2.5" and Quantity["2.3s"]. How can the numeric value be extracted to have: ...
0
votes
4answers
49 views

How to trim out sequence of blank-spaces?

Considering we have few strings: s1 = "dasbdk " s2 = "asdnkal asn knkl nkn dvklsn " s3 = " jbjkbasd nklnkln " Q1: How can the blank-spaces in ...
3
votes
2answers
147 views

Rule transformation between letter and number

I have a global rule as follow: ...
8
votes
3answers
214 views

Mathematica equivalent to Python long raw strings? handling escape characters in packages

I'd like to write the following in plain text .m file in Mathematica, without having to double escape all the Latex commands: ...
0
votes
0answers
52 views

Shortest Common Superstring for all k-length strings on an alphabet

Given all strings of length $k$ of an alphabet of size $n$. This gives $n^{k}$ strings. Now I want to create one superstring that contains all these strings as substrings. They hopefully strongly ...
0
votes
0answers
38 views

Stringifying $GeoLocation for the browser

Currently, when I ask for ExportString[{"geoLocation"->TextString[$GeoLocation]},"JSON", "Compact"->True] I get this: ...
8
votes
1answer
119 views

Naming a pattern changes outcome in StringCases[]

s = "1 2 "; StringCases[s, (n : NumberString ~~ " ") .. ] StringCases[s, (NumberString ~~ " ") .. ] yields ...
0
votes
1answer
53 views

Replacing every nth comma in string output with “\n” [closed]

Feels like a strange question to ask, but I basically have a string with sets within sets, and it seems like the simplest formatting solution to seeing the data without needing to import everything ...
5
votes
2answers
93 views

Dataset breaks multi-character StringSplit

Given ds = Dataset[{"a b", "c-d"} ] multi-character StringSplit is broken with Dataset ...
0
votes
2answers
65 views

Match groups in regular expressions

I'm trying to understand Mathematica's pattern matching in strings, but I have some doubts. 99% of the time I need to a) check if a match occurs and b) retrieve the matched patterns. I come from ...
1
vote
3answers
210 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: ...
5
votes
1answer
85 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
80 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
55 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
62 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
68 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
45 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
73 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 ...
0
votes
2answers
86 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. ...
5
votes
3answers
117 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 ...
10
votes
2answers
139 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 ...
1
vote
1answer
78 views

Dealing Repeated pattern in StringReplace

A problem about StringReplace When I'm running into this problem possible [bug] ...
4
votes
3answers
182 views

How could I transform the YYYYDDD date string/Integer to YYYYMMDD date string?

suppose I have lots of YYYYDDD date Integers which look like(for example): ...
1
vote
5answers
150 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" ...
0
votes
2answers
37 views
1
vote
2answers
54 views

Trouble with ToString and StringForm

The command ToString[StringForm["SomeText=`` as well as OtherText=``.", "textA", "textB"], FormatType -> InputForm] produces the output ...
2
votes
4answers
218 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
93 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 ...
3
votes
0answers
46 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 ...
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 ...
1
vote
3answers
195 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: ...
1
vote
2answers
78 views

How do I use ReplaceAll to replace strings of a specified form?

Why is "Xabcde" /. "X" ~~ e__ -> e "Xabcde" and not "abcde"
2
votes
5answers
84 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: ...
2
votes
3answers
119 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 ...
30
votes
2answers
685 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: ...
0
votes
1answer
48 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 ...
0
votes
1answer
43 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 ...
2
votes
1answer
93 views

How to parse string to expression? [closed]

When trying to make a string an expression I see some wrong results: ...
13
votes
7answers
769 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
1answer
36 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: ...
3
votes
1answer
101 views
7
votes
4answers
439 views

Strange answer from StringReplace

I have a list of strings and I would check if there is an empty string element, that's "", because I need to replace it with a "0". I try the following ...
0
votes
2answers
69 views

Get a filename used in an import and store it as a variable

Hopefully a simple one for you (or at least seemingly)! I import a .txt file, from which i make a ListLinePlot. I simply want to read in the name of the file, store it in a variable so I can use it ...
2
votes
1answer
111 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 ...