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

learn more… | top users | synonyms (2)

1
vote
1answer
43 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
1answer
48 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
1answer
56 views

Elegant way to drop rest of a sting at the occurance 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
118 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
0answers
32 views

Dealing Repeated pattern in StringReplace

A problem about StringReplace When I'm running into this problem possible [bug] ...
3
votes
3answers
131 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
139 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
36 views
1
vote
2answers
44 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
199 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
85 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
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 ...
5
votes
4answers
709 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
182 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
71 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
70 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
110 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 ...
29
votes
2answers
633 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
43 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
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 ...
1
vote
1answer
67 views

How to parse string to expression? [closed]

When trying to make a string an expression I see some wrong results: ...
13
votes
7answers
758 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
31 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
93 views
7
votes
4answers
436 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
57 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
95 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 ...
0
votes
2answers
44 views

SequenceAlignment behavior

When I do: SequenceAlignment["-0.999995756767227832383453368554576431549","-0.999995756767227832383346049698547342279"] I get: ...
3
votes
2answers
143 views

Please help translate regular expression to StringExpression

I am familiar with regular expressions in other languages (e.g., Perl, Python, ViM), but the Mathematica StringExpression is baffling me. I'd like to match strings ...
3
votes
1answer
38 views

How to process Result of StringReplace?

StringReplace["item_10", "item_" ~~ x__ -> x + 1] returns "1+10" How can I force it to evaluate to 11?
1
vote
2answers
89 views

How do I make a single character bold?

I have a string of characters, like "CDABOZPVRYXSWQEGNILUTHMKJF" and want to convert it to a string in which the character at position ...
5
votes
5answers
276 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 ...
0
votes
2answers
64 views

Using StringReplace to make file names

Often I'm making many plots for different values of parameters. Each plot has a nice PlotLabel with superscripts, subscripts and some special characters. I would ...
1
vote
1answer
61 views

Are all of the numbers in my file legitimate hex numbers

I have about 10,000 hexadecimal numbers (32 digits each) in an excel file, in one column. I want to verify that all of them are indeed hexadecimal number and that no other characters are present. My ...
0
votes
2answers
78 views

Is there a manual way to generate a string of zeroes with a 2 at the end?

How do I get mathematica to display 33141015 zeroes and a 2 I've tried using 2*10^-33141016 but it just gives me scientific notation Is there a manual way to generate a string that looks like ...
3
votes
2answers
199 views

Regular expression too large problem

pattern = Names["*"]; StringMatchQ["Bold", pattern[[1 ;; -1 ;; 2]]] (* True *) StringMatchQ["Bold", pattern] Error Information: ...
3
votes
1answer
47 views

Is the use of StringTemplate with a styled string documented behavior?

I was pleasantly surprised to find out that StringTemplate appears to work with styled (formatted) strings, with the style of the slots applied to the inserted ...
2
votes
0answers
91 views

How to efficiently find parts of a string with beginning and ending specified?

I'm trying to find specific URL addresses from a html document. The addresses can be found between the strings "href=\"" and "\" class=\"listing". The problem is not including strings like this: ...
8
votes
2answers
123 views

Convert recursive RegularExpression to StringExpression?

Consider the following expression for matching balanced brackets: ...
0
votes
2answers
49 views

import string to data

...
4
votes
3answers
183 views

How can I improve NumberString?

I would like to test strings to see if they represent numbers. This should include number representations with precision marks and scientific notation. NumberString ...
1
vote
2answers
64 views

Why doesn't ToString work in ReplaceAll? [duplicate]

I'm trying to use ReplaceAll in a subscript. However, it doesn't seem to work as expected if I want to use the output the subscript in a ...
5
votes
1answer
165 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 ...
3
votes
1answer
77 views

Strings with exclamation marks in Mathematica [duplicate]

Given this input FullForm[ToString[TraditionalForm[x]]] Mathematica outputs "\!\(TraditionalForm\`x\)" It seems like ...
6
votes
1answer
139 views

Limit characters/digits entered into InputField

When using InputField, whether setting the input type as a Number or String, is there a way ...
1
vote
1answer
58 views

Using the string Match with options! [duplicate]

Here is what I want to do: I have a list of strings for example s={"red carpet","red box","black carpet","black box"} I want to use something like ...
6
votes
3answers
301 views

Finding all sublists or substrings of a given list/string

Given a list or string, how do I get a list of all (contiguous) sublists/substrings? The order is not important. Example for lists: ...
5
votes
5answers
197 views
4
votes
1answer
70 views

How to convert expression with Subscript to string

I've tried ToString[], but it doesn't work properly with subscripts: How to convert expr with subscript to string with exactly the same FullForm that "expr" has?
4
votes
1answer
96 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...