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

learn more… | top users | synonyms (2)

3
votes
2answers
74 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: ...
0
votes
2answers
144 views

Exctrating data information from a file.txt

I really did previous long search in the site and I couldn't find any answer that might help me. So I am asking it. I have the following data set, ...
5
votes
3answers
388 views

Camel hump string split

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

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
0
votes
1answer
67 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: ...
0
votes
2answers
69 views

Decimal-to-ASCII conversion

I have to write a program that converts a number (decimal notation) to an ASCII string. For example, x = 26728 (or 0x6868) and the string is "hh". I wrote this, but it seems that it is not the ...
1
vote
0answers
66 views

Geodesy without units?

Suppose I'm interested in the latitude of Los Angeles and I do the following: ...
1
vote
0answers
43 views
0
votes
1answer
64 views

Data file organized in strings

I am working in a data set : The original question, They are strings of thousands stars,and each one contains a lot of parameters, and the following item is called identifies, they are the names ...
7
votes
1answer
123 views

LetterCharacter for Cyrillic symbols

Why does the code StringMatchQ["ы", LetterCharacter] return False? Probably because: ...
10
votes
2answers
140 views

Unexpected result from StringReplace

The following works as expected. StringReplace["xxxyxz", "x" ~~ _ -> "ww"] "wwwwww" And so does this. ...
23
votes
1answer
272 views

StringCases is Confused with Patterns in Version 10.0.1

I observed the following with StringCases when trying to use rules/patterns. Here is a screenshot of the behavior: Not only is the pattern highlighted in red, ...
1
vote
1answer
48 views

Optimizing alphametrics code

First of all, thank you all in this great community. I have been reading a lot of threads about Mathematica optimization learning things like using Compile ...
6
votes
4answers
165 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 ...
11
votes
3answers
249 views

ToExpression fails with long nested string expressions

Consider the following conversion from String to Mathematica Expression: ...
0
votes
0answers
23 views

Error when converting a string involving superscript after closing square bracket using ToExpression

I would like to store a piece of code in the form of a string, make some string transformation to it and get the new code evaluated using ToExpression. Everything works just fine but one: if there is ...
16
votes
2answers
548 views

Why is TextString[-0.5] a positive number?

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 result of my 3-weeks ...
2
votes
2answers
122 views

how to extract the string using regular expressions

I have the list : a1 = {"struct name1 {","struct name2{","struct name3{","struct name4{", "struct name5{","struct lastStruct{"} I tried to extract the ...
1
vote
1answer
129 views

how to make a recursive function to analyse this file

I am stuck at this problem beginning We assume we have keyword k, and the structure in the file: file.txt ...
3
votes
1answer
44 views
2
votes
1answer
51 views

How can I automatically name files being exported based on input parameters

I have Mathematica notebook that performs some operation say a=2 b=3 c=5 d=4 how do I set the output file after evaluation to be named using the values ...
1
vote
1answer
52 views

Find item in a big list that contains a specific string [closed]

I have a huge list with 17,576 (=26^3) items in it. All items consist of a long string of text about 1,200 or so characters long. These strings were all generated ...
1
vote
1answer
34 views

Creat a global variable from an argument and being able to use it as a numeric input

I want something like this: myfun[j_]:=Block[ {ans}, ans = Range[j]; "phi"<>ToString[j] = Total[ans]; ]; The procedure is just an illustrative ...
0
votes
1answer
52 views

TraditionalForm for PlotLabel with a parameter

This is a simple variation/spin off of this question, but I am having trouble. In the second example in the original question, I'm trying to get the $a=$ in the ...
31
votes
1answer
534 views

Why is StringExpression faster than RegularExpression?

Edit: as noted by Albert Retey the performance difference is only seen when sub expression extraction is performed. If this test is used below the timings are similar: ...
6
votes
4answers
607 views

Caesar's cipher

How can Caesar cipher be implemented? I want to use StringReplace but I don't know how to write the replacement rule to replace the characters with, say, the ...
3
votes
3answers
199 views

String pattern defined by number of characters

I want to extract non-overlapping substrings from strings with only four possible characters a,b,c,d. These strings will always have equally many "a" and "d" characters. The substrings x I want satisy ...
15
votes
3answers
465 views

Grabbing a number of characters around a string pattern

If I have some string data: text = StringTake[ExampleData[{"Text", "DeclarationOfIndependence"}], 400] "When in the Course of human events, it becomes ...
28
votes
4answers
3k views

Looking for “Longest Common Substring” solution

I'm looking for robust code to solve the "Longest Common Substring" problem: Find the longest string (or strings) that is a substring (or are substrings) of two or more strings. I can just code it ...
6
votes
3answers
175 views
2
votes
1answer
34 views

Linear function on strings using UpValues

I have two functions Sup and Sdown that take a string of letters with allowed characters ...
6
votes
1answer
176 views

Returning computable numbers from WolframAlpha

WolframAlpha["Apple company revenue", {{"Result", 1}, "Plaintext"}] Desired output 182800000000 ...
1
vote
1answer
52 views

Insert a linebreak and character repeatedly into a matrix output which is in fortranForm

Suppose I have a very long string which is a11 element of matrix a11=2*gopsv-2*Bgopsvw+2*acgmops*v+2*cgmopsv*B-2*acgmopsvB+3*gmopsvB-3*BgmopsvwB+m*w2*B +5*acgm2 +opsvB -ac*m2*w2*B +cgm2*opsvB* - ...
35
votes
8answers
5k views

How do you convert a string containing a number in C scientific notation to a Mathematica number?

Suppose I have a string containing the C-representation of a floating point number, for example s = "1.23e-5" and I want to convert this to a Mathematica number. ...
3
votes
2answers
76 views

Removing non-word characters in certain parts of a string

I would like to ask how I can remove non-word characters from a string, but only in certain cases. I have read this article, so I know how to get the words out of a string. My text is however a bit ...
1
vote
1answer
51 views

Importing file as a string causes a puzzle

I generate simple txt file and import it as follows: a = Import["binary.txt"]; b = Import["binary.txt", "String"]. It appears then that lengths of imported strings ...
1
vote
2answers
101 views

How to solve ArcSinh equation for many differents parameters?

I am totally stuck trying to solve the equation below (1/2) x Sqrt[1 + 4 a^2 x^2] + ArcSinh[2 a x]/(4 a) == d Where a and ...
8
votes
3answers
333 views

How to parse information contained in a file name

I have a set of files containing my data, and the file-names contain relevant information that I would like to extract. What I have is: ...
4
votes
1answer
200 views

How do I remove single-character whitespace between words, leaving multiple, contiguous, whitespace characters unchanged?

In a string, I want to remove only the single-character whitespace between printing characters, leaving any multiple, contiguous, whitespace characters between printing characters unchanged? What is ...
2
votes
2answers
163 views

Difference between double quotes

I have a notebook and I enter something like PlotLabel->"my label with dynamic number "<>ToString[strange] and I get errors like However, the double ...
1
vote
2answers
60 views

Generate a sequence of names such as a1, a2, a3 [duplicate]

How do I generate the sequency {disp1, disp2, disp3, ...}? I tried the following but it didn't give me what I expected: ...
3
votes
5answers
205 views

How to join two strings one of which is Subscript?

If I write this one str=Subscript["x","y"]; StringQ[str] False How can I get str as string?
2
votes
4answers
118 views

Finding relevant parts in XML document

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

Graph showing valid English words obtained by insertion of single characters

I'd like the most efficient Mathematica code for making a formal tree graph whose nodes are valid English word strings (in DictionaryLookup[ ]) and directed links represent the relation 'insertion of ...
1
vote
1answer
68 views

Transforming a nested list for textual output

Hello I have a data structure based on lists, with items, subitems and subsubitems, and I want to display a textual output with a description. ...
5
votes
1answer
162 views

Conditional string replacement

I have a list of text and need to replace an element based on the text that appears in the element before it. Example of my list: ...
1
vote
2answers
75 views

How to define a function that counts the exponents

I want to define a function $F$ described as follows: The input of $F$ is a polynomial such as m*u*x^4*y + n*v*x^2*y^3 where $m$ and $n$ are constants, and ...