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

learn more… | top users | synonyms (3)

8
votes
1answer
155 views

How to change the font color of a variable in whole input cell

I want to track the occurrence of a particular variable in a code. So the idea is to change its color. Usually I do it in a crude way - convert the code into text and then use ...
1
vote
2answers
42 views

How to define a function `deriv[f[x]]` such that its output is an unevaluated expression `fx=D[f[x],x]`?

I want to define a function deriv[f_[x_]] such that when I run deriv[f[x]], the output is an unevaluated expression ...
2
votes
1answer
45 views

How to extract part of association?

Considering an association: asc = <|"a"->1, "b"->2, "c"-><|"e"->3, "c"->4|>, "d"->5, "e"->6, "f"-><|"g"->7|>|> How ...
4
votes
2answers
62 views

Usage of StringTemplate

The documentation for StringTemplate has the following example ...
5
votes
1answer
44 views

Export XMLElements with MathML contents

Setup Here's my mathML expression: mathML = ExportString[1/2, "MathML"] ...
3
votes
1answer
187 views

Decode a text which is encoded with UTF-8

I would like to decode a text which is encode with UTF-8. My code is here : ...
0
votes
0answers
38 views

UnitConvert is fun, but how to remove the Units from a UnitConverted expression? [closed]

This is certainly something that Mathematica didn't intend but... For example: ...
6
votes
1answer
67 views

A possible bug about WordCharacter on CJK characters

According to the documentation of WordCharacter: WordCharacter matches any character for which either LetterQ or DigitQ yields True. However, the results of the following code seem not ...
0
votes
1answer
29 views

How can I name to a saved file with the numerical values of some specific parameters? [duplicate]

I'm using some parameters to determine the elements of a list. I want to save this list with DumpSave, but I need to name it with its parameters. For example, I use the following parameters ...
2
votes
1answer
46 views

How to insert a character in a string with condition?

Considering we have a string: str = "1a 789 4/7 123/7 asff %$#7 478 9/4" How can I insert "/1" for the numbers that are ...
0
votes
1answer
34 views

StringJoin Dynamic problem [duplicate]

My goal is to import a XML file from the site fueleconomy.gov to get a list of cars dependent on the year given as the user input . Here is the code: ...
1
vote
0answers
21 views

Use functions to call a named object [duplicate]

Now I have several interpolation functions called x30, x50, z30, z50...... I wish to write a function to call these function by inputing x or z and numbers automatically, and assign a argument x to ...
15
votes
0answers
169 views

Mma 10.2 `Alphabet` and `LanguageData` give different and both erroneous list of letters

The new function Alphabet introduced in Mathematica 10.2 gives the wrong list of letters for the Spanish language in my system (Windows 7 64 bits). ...
0
votes
2answers
92 views

String quotes elimination

I'm trying to import a .csv file that contains some points which are geo-positions, but the import gives me the points wrapped in quotes. Is there any method to get them as pairs of real numbers? I'm ...
0
votes
0answers
48 views

How to parse fraction to a number?

Considering a fraction: val = "F \!\(\*FractionBox[\(1\), \(1\)]\)"; I extract the part of interest: ...
1
vote
1answer
47 views

How to rationalize real number in string?

Considering we have: in = "F 18/10" How can I make this to be: Thanks!
5
votes
3answers
210 views

how to concatenate a list of a list of strings

I have two lists of lists, La and Lb that I want to concatenate so that every element of a list n in La is concatenated with the corresponding element of list n in Lb. For example: La = {{P, O, O, ...
4
votes
2answers
67 views

How to delete blank valued keys from nested association?

Considering we have: acs = <|"A" -> <|"a" -> " ", "aa" -> "asd"|>, "B" -> <|"bb" -> " "|>|> How can we come to have a result ...
3
votes
3answers
140 views

How I can count multiplications in an experssion?

Next task to complete: Count *-symbol in such expression as a + s^2*b - c/y + o^3 + n*m*u (in this case count of ...
6
votes
3answers
333 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
vote
1answer
88 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
41 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
358 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
41 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
165 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
51 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
154 views

Rule transformation between letter and number

I have a global rule as follow: ...
9
votes
3answers
232 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
55 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
41 views

Stringifying $GeoLocation for the browser

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

Naming a pattern changes outcome in StringCases[]

s = "1 2 "; StringCases[s, (n : NumberString ~~ " ") .. ] StringCases[s, (NumberString ~~ " ") .. ] yields ...
0
votes
1answer
56 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
99 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
215 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
87 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
81 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
58 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
66 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: ...
2
votes
2answers
119 views

Input a non-string input — output as a string

I am trying to create a function that needs to transform its input into a string. The objective is to transform a $\LaTeX$ mathematical expression into an executable Mathematica expression. ...
0
votes
2answers
46 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
76 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
92 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
120 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
151 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
79 views

Dealing Repeated pattern in StringReplace

A problem about StringReplace When I'm running into this problem possible [bug] ...
4
votes
3answers
204 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
154 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
59 views

Trouble with ToString and StringForm

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