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

learn more… | top users | synonyms (3)

1
vote
3answers
86 views

Keep leading/trailing zeroes (like Defer except with numbers) in a given number

I'm trying to write a function that counts the number of significant figures a given number has so I can ensure my calculations are rounded correctly; however, I am having a lot of trouble preventing ...
4
votes
4answers
192 views

Finding relevant parts in XML document

My question is about a XML document and finding parts of strings. test = Import["C:\\Users\\filename.xml", "XMLObject"] This gives the following output: ...
0
votes
0answers
42 views

Transformation Matlab assignements (with vectors and matrix) To Mathematica equations

In a previous post Transformation Matlab assignements To Mathematica equations, thanks to your help, I could transform Matlab assignments to Mathematica equations by using ReplaceString function. I ...
5
votes
3answers
310 views

Finding all of the words containing certain letters

Is there a fast method to find all of the words containing the letters: {a, e, i, o, u, y}? I created an algorithm, but it takes more than 11 seconds to find all of ...
4
votes
2answers
65 views

Using parenthesized Regex backreferences in StringReplace

(I am sorry for my poor English,I'll try to use a simple sentence to convey me.) I can use StringCases to get the target to change like this ...
1
vote
1answer
59 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 ...
1
vote
1answer
39 views

How to reference StringExpression named parts from a package without full Context path?

I have a long StringExpression in a package returned by a function. There are some named parts in the expression that I would like to reference when I use the ...
1
vote
2answers
47 views

Detect Mathematica operators eg. \[CircleTimes] in strings

I'm trying to detect all Mathematica operators/symbols (eg. [CircleTimes], [Colon], etc.) in strings so I can replace them with something else, how can I achieve that?
1
vote
1answer
27 views

FromDigits gives “not a list of digits” error for integer string in StringExpression rule of StringCases

I have large StringExpression that is used in StringCases. Some of the parts being pulled out are integer strings. These pull ...
1
vote
2answers
100 views

ToExpression and Fortran notation

ToExpression["9.0E-03"] interprets the string as 9*e - 3 instead of what I am expecting: ...
21
votes
1answer
479 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 ...
7
votes
2answers
95 views

Strange Error on Fresh Kernel (10.2)

Bug introduced in 10.1 I wrote a helper function to format real numbers in a certain format for writing .dbf files here. It relies on a new function to 10.1 - ...
5
votes
1answer
142 views

Escaping multiline strings in Mathematica

I want to assign long multi-line strings in Mathematica. Is there a way of delineating a block without having to escape each instance of '"' with '\"' and each line ending with '\'? i.e. In other ...
2
votes
3answers
175 views

Problem displaying uppercase “I” in a string [duplicate]

It seems that Mathematica reserves the capital i, I, for the imaginary unit. I have the following expression: expr = a.b + II ...
12
votes
4answers
370 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 ...
6
votes
4answers
267 views

Shorter shorthand for StringJoin[]?

As a minimal working example: myString="some words"; myString=myString<>"more words"; Is there a shorter way to tell Mathematica that I want to "tack on" ...
8
votes
1answer
161 views

Simple string pattern crashes kernel

Bug introduced in 6.0 or earlier and fixed in 10.1.0 The following code crashes my Mathematica kernel (v9, MacOS): ...
24
votes
1answer
307 views

StringCases is Confused with Patterns in Version 10.0.1

Bug introduced in 10.0.1 and fixed in 10.0.2 I observed the following with StringCases when trying to use rules/patterns. Here is a screenshot of the behavior: ...
6
votes
7answers
348 views

Convert array from {{…}} to “[[…]]”

I have made this function: conv01 = Map["["<>StringJoin@@Riffle[#,","]<>"]"&,Map[ToString,#,{2}],{0,1}]& to convert: ...
3
votes
1answer
172 views

Using Probability for n-gram string queries

I want to use Probability to ask questions on strings like "what's the probability of the occurrence of the trigram 'the' conditioned on the occurence of the digram 'th'?" This doesn't work. I ...
8
votes
1answer
166 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 ...
20
votes
2answers
587 views

Why is TextString[-0.5] a positive number?

Bug introduced in 10.0 and fixed in 10.0.2 I want to format numbers in decimal notation and chose TextString for this task. But today, when looking at the final ...
1
vote
2answers
44 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 ...
33
votes
2answers
799 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: ...
2
votes
1answer
47 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
66 views

Usage of StringTemplate

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

Export XMLElements with MathML contents

Setup Here's my mathML expression: mathML = ExportString[1/2, "MathML"] ...
3
votes
1answer
218 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 : ...
3
votes
1answer
50 views

Sort Unicode characters

Sorting ASCII phrases works fine: Sort[{"albatrob", "abo", "dict", "star", "mangel", "m"}] (*{"abo", "albatrob", "dict", "m", "mangel", "star"}*) But unless I'm ...
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 ...
15
votes
0answers
184 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
1answer
31 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
48 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
35 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 ...
9
votes
3answers
236 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
2answers
93 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
50 views

How to parse fraction to a number?

Considering a fraction: val = "F \!\(\*FractionBox[\(1\), \(1\)]\)"; I extract the part of interest: ...
0
votes
3answers
112 views

Positions of a string in a list [duplicate]

Sorry for the bad title..Didn't know how to describe this, feel free to change it to be more specific. I have a list in this form: ...
1
vote
1answer
51 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
220 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, ...
2
votes
2answers
123 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. ...
4
votes
2answers
69 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
141 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
339 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
94 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 ...
12
votes
3answers
333 views

ToExpression fails with long nested string expressions

Consider the following conversion from String to Mathematica Expression: ...
2
votes
2answers
85 views

Using Table with arbitrary number of variables [duplicate]

Let $P=\{p_1,...p_n\}$. I would like a way to implent Table[Expression,{$p_1$,lim},{$p_2$,lim},...,{$p_n$,lim}] where n and lim are parameters defined by the user. Any ideas?
1
vote
1answer
47 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 ...