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

learn more… | top users | synonyms (3)

10
votes
3answers
186 views

How do I make a string literal without having to escape backslashes?

I'd like to say something like: foo = @"\abc\def\ghi" instead of foo = "\\abc\\def\\ghi" How do I do this? This would ...
10
votes
3answers
363 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 ...
2
votes
3answers
171 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
53 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
158 views
0
votes
0answers
56 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
42 views

Stringifying $GeoLocation for the browser

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

Naming a pattern changes outcome in StringCases[]

s = "1 2 "; StringCases[s, (n : NumberString ~~ " ") .. ] StringCases[s, (NumberString ~~ " ") .. ] yields ...
0
votes
1answer
60 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
100 views

Dataset breaks multi-character StringSplit

Given ds = Dataset[{"a b", "c-d"} ] multi-character StringSplit is broken with Dataset ...
7
votes
1answer
165 views

Unicode beyond Basic Multilingual Plane

String manipulation takes a dive when characters beyond \:FFFF are used e.g. Mathematical Alphanumeric Symbols. The characters display fine but doing string ...
0
votes
2answers
67 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 ...
5
votes
3answers
501 views

Camel hump string split

Given System names of 2 or more characters: systemNames = Names["System`*"] // Select[StringLength[#] > 1 &] ; Is ...
0
votes
2answers
97 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
83 views

Dealing Repeated pattern in StringReplace

A problem about StringReplace When I'm running into this problem possible [bug] ...
5
votes
3answers
121 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
167 views
1
vote
3answers
218 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
217 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
92 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
82 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
64 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
70 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
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
77 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
158 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
3answers
202 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
230 views
26
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
63 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
156 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
104 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
225 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
97 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
129 views
5
votes
4answers
714 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
49 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 ...
1
vote
2answers
97 views
2
votes
5answers
92 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
302 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
129 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 ...
15
votes
2answers
200 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
243 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
784 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
47 views

SequenceAlignment behavior

When I do: SequenceAlignment["-0.999995756767227832383453368554576431549","-0.999995756767227832383346049698547342279"] I get: ...
12
votes
3answers
783 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
192 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 ...
25
votes
6answers
759 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 ...