Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1997

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

3 votes

How do I extract a number from a string?

Consider: str = "thiru37aa2er45" then StringCases[str, DigitCharacter ..] yields: {"37", "2", "45"} StringCases[str, DigitCharacter .] yields: {"3", "7", "2", "4", "5"} They can be conve …
ubpdqn's user avatar
  • 64.8k
18 votes

How can I generate a list of combinations of string joins?

You can also use Tuples: a = {"a", "b", "c"}; n = {"1", "2", "3"}; StringJoin @@@ Tuples[{a, n}]
ubpdqn's user avatar
  • 64.8k
3 votes

How to join two strings one of which is Subscript?

In Mathematica version 10, StringTemplate can allow you to convert to string, e.g. st = StringTemplate[ "Pythagoras theorem: \!\(\*SuperscriptBox[\(`1`\), \ \(2\)]\)+\!\(\*SuperscriptBox[\(`2`\), …
ubpdqn's user avatar
  • 64.8k
2 votes

How do I complete this function len for the length of a line segment?

If your aim is to measure multiple line segments you can apply your function or in-built functions to list. You can also use RegionMeasure (1 dimension) or ArcLength for Line. Consider the polygon: …
ubpdqn's user avatar
  • 64.8k
1 vote

Options in a StringReplace rule

Perhaps not what you are after: op[] := Function[x, x /. MapThread[ Rule[#1, (#2)] &, {{"t", "t1", "t2"}, Thread["t" -> {"0", "T1", "1"}]}]]; srf[opts_: "t"] := StringReplace["content …
ubpdqn's user avatar
  • 64.8k
4 votes

How to switch between a binary number as String and a as a list of digits?

Just some other functions to consider: IntegerDigits an take a base argument, e.g. IntegerDigits[5,2] yields {1,0,1} FromDigits is the inverse: FromDigits[{1,0,1},2] yields 5 If the issue is for di …
ubpdqn's user avatar
  • 64.8k
8 votes
Accepted

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

Perhaps, using: dateslalala={2003364, 2003157, 2003314, 2003302, 2003181, 2003062, 2003254, \ 2003070, 2003365, 2003338, 2003233, 2003073, 2003020, 2003010, \ 2003238, 2003107, 2003310, 2003347, 2003 …
ubpdqn's user avatar
  • 64.8k
1 vote

Replacing every nth comma in string output with "\n"

I am somewhat confused about the aim. Here is an interpretation. Starting with string: string = "{{13,{17,4},{23,10},220/13,3},{17,{23,6},{29,12},4368/17,3},\ {19,{23,6},{29,12},4368/19,3},{23,{29,6} …
ubpdqn's user avatar
  • 64.8k
2 votes

Adding numbers to a list

Note you could just do: Sort["x" <> ToString[#] & /@ Range[12]] If you have list you can also use MapIndexed: xs = ConstantArray["x", 12]; Sort@MapIndexed[#1 <> ToString[#2[[1]]] &, xs]
ubpdqn's user avatar
  • 64.8k
2 votes

Applying different values to string row

Perhaps: t = {1, 4, 4, 22, 3, 12, 54, 65}; a = ">}{<" Row[{"{<"}~Join~Riffle[t, a]~Join~{">}"}] or l = "{<"; r = ">}"; Row[{l, ##, r} & @@ Riffle[t, Row[{r, l}]]]
ubpdqn's user avatar
  • 64.8k
7 votes

Characters to numbers

v = ToExpression /@ StringSplit["000101", ""] yields: {0,0,0,1,0,1} ToExpression["000101"] yields: 101
ubpdqn's user avatar
  • 64.8k
2 votes

Element combinations

SplitBy[lis,NumericQ] /. {{x__String} :> StringJoin[x], {x_?NumericQ} :> x}
ubpdqn's user avatar
  • 64.8k
4 votes

Sorting alphanumeric strings

Narrow but FWIW: strings[[Ordering[(Characters /@ strings) /. {{x_, y_} :> {x, 0, y}}]]]
ubpdqn's user avatar
  • 64.8k
2 votes
Accepted

Importing data to make a DateListPlot

I make the assumption that your imported data is of the form {{20131217, 123123.}, {20140313, 321321.},...}. If the date is a string then omit the String function in the following. You need to convert …
ubpdqn's user avatar
  • 64.8k
5 votes

Graph showing valid English words obtained by insertion of single characters

I post this (if I understand the question from title and text: single letter addition anywhere in string) to illustrate how unwieldy the graph gets just 3 levels deep. Here just starting with "a". fu …
ubpdqn's user avatar
  • 64.8k

15 30 50 per page