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

learn more… | top users | synonyms (2)

3
votes
1answer
45 views

What string pattern will match $n$ contiguous characters drawn from a given alphabet?

I'd like to use StringCount to count the number of subwords in a string that have the form **** where ...
0
votes
0answers
45 views

Read in bezier curve from svg file

I am trying to do some calculation of some svg file,After read in with Import["filename","XML"]and some easy operation, I can get the string of the bezier curve, ...
4
votes
2answers
91 views

Counting the number of instances of one sub-string within a given string within a lower- and upper-bound gap of a second sub-string

Please consider the situation where I give you a list where entries are drawn from a fixed set of characters: ...
3
votes
1answer
66 views

How can I get precise frame rates in dynamic?

I've been the Spritz sdk in my ios apps, and I love it. For funsies I wanted to see how much less code a mathematica version would take! Using dynamic I get a nice result, shown below in code. ...
22
votes
9answers
3k views

Programming paradigm change

I'm new to Mathematica, I've been learning by myself, and, being a Java developer for some time, it makes it hard to adapt. I've tried to solve a Reddit challenge, and I came up with this solution: ...
2
votes
1answer
44 views

Reversibly abstracting a list of strings as a graph object where vertices represent strings and edge connect pairs of strings based on various tests

Imagine I provide you a list of arbitrary strings, say: Map[StringJoin, Tuples[{"0", "1", "2"}, 4]]. I'd like to abstract these strings as a graph object in ...
2
votes
3answers
84 views

String formatting

I have the following string: "174,861.00 ( 4,053.52) 206,850.48 118.29 ( 31,989.48)" Parentheses stand for negative numbers. I will like to get ...
1
vote
1answer
77 views

How do I use wildcard characters with StringTake?

Say I'd like to pick substrings from some string such that these substrings have the pattern @@@q@@@, where @ is used here as a ...
1
vote
2answers
73 views
2
votes
1answer
51 views

Importing a Base64 encoded string

everyone, I'm handling some paragraphs enconded with Base64 from CSV file format. The problem is that Mathematica can't decode it. It seems Mathematica Encode/Decode their own Base64. I'm thinking ...
2
votes
2answers
85 views

Highlighting or coloring certain words / substrings appearing in a larger string

I have one longer string, longString, and a set $S$ of shorter strings {ss1,ss2,ss3,...}. I'd like to print out ...
1
vote
2answers
103 views

Deleting all characters in a string that do not belong to a small set of elements

Say I have a string {100 aa bbc%j%b%wa ajjcj11j0%2wj fc} with a lot of undesired characters or spaces in it, for example: {" ", "%", "w", "j"}. I'd like to strip the string of these characters, with ...
1
vote
1answer
50 views

using deletecases for twittermessages using the timestamp

I have a Excelsheet with tweetsmessages. These tweets are all written in Dutch. I would like to analyse these tweets in relation to the timestamp. ...
0
votes
2answers
52 views

Convert epoch seconds to date [duplicate]

I have got the following datetime from an API: 1395401384298 I am guessing it is in epoch miliseconds time (it should be one day in 2014) How can i convert it into a more readable String? I have been ...
5
votes
5answers
266 views

Joining some strings in a list of strings

So, say I have a list of strings, representing lines in a file, like so: ...
4
votes
1answer
104 views

How to differentiate between formatted and unformatted strings?

StringQ returns True both for unformatted and internally formatted strings. To get True only for unformatted ones I have thought up the following function stringQ. Please, can you point out ...
0
votes
2answers
48 views

ToExpression an array

I have a .dat file. I would like to convert a big array of strings(that's what I havein the .dat file) into an array of numbers, for example ...
1
vote
2answers
43 views

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

I was trying with String Functions and I viewing any posts and have no results I want to know 1.- From cromo33 = Table[RandomInteger[], {i, 1, 33}] cromo33 ...
0
votes
1answer
42 views

Replacing whole strings

I imported a text and seperated al words by using StringCases. After this I would like to manipulate the text, for example to replace all singular verbs to plural. ...
11
votes
5answers
1k views

What is the fastest way to extract a substring from a huge string?

I develop an algorithm to find the most common substrings of a given length n up to a certain distance l in front of a pattern p in a huge sequence S. E.g. I want to find the most common hexamers ...
2
votes
1answer
48 views

How to put Labels in of a list of number in a chart?

I can´t put the labels 0,....,31 in this simple chart on the usual place, or better just over the Top of each bar How should I do? ...
5
votes
2answers
121 views

Using StringCases and treating certain phrases as single words

My question is about StringCases. When I use this function, each word is separated by a ,. But I want some noun phrases like ...
3
votes
3answers
103 views

Removing non-word characters from a string

I'm trying to get a list of words from a string. Sounds like an easy task for Mathematica. I have the following code: ...
0
votes
1answer
82 views

Importing data to make a DateListPlot

I am having a hard time trying to import some text data for later use in DateListPlot. My first field in my data is a date of the format "yyyymmdd". I tried to ...
3
votes
1answer
200 views

Paste letter grades B+ , C-, A, B into notebook and not get B+C-AB

I have worked for two days to find a way through this problem. I am porting my student grade records into Mathematica from spreadsheets, or sometimes from my college web sites, or sometimes from my ...
2
votes
3answers
138 views

Insert a linebreak and character repeatedly into a very long string

Suppose I have a very long string ...
0
votes
1answer
46 views

Generalizing Characters to n-character substrings

I'm doing some frequency analysis on an encrypted plaintext. Tally[] and Characters[] make the basic task quite easy. To count the number of times each character appears (sorted alphabetically; ...
3
votes
1answer
94 views

String pattern matching in function definition

I have a function f and its downvalues. I want to code an extra downvalue for arguments of the form "part1:part2" I don't understand why ...
2
votes
1answer
74 views

How do we make a negative integer out of a string of a negative number and vice-versa?

Negative numbers are not taken into consideration by mathematica's built-in functions. FromDigits["-2"] Gives me this message: ...
0
votes
3answers
80 views

string to complex number

Consider the following list MyList= {-0.0000396, -0.0000187167, "0.10259130990561813-0.0677132394802944i"} Head /@ MyList (* -> {Real, Real, String} *) In ...
0
votes
1answer
124 views

Extracting coefficients from multiple equations and generating coefficient matrix

after 6 hours reading about string patterns, string manipulations and trying ..and trying..I officially give up (for now) and ask for some help. I have some unorderly equations you will find here ...
5
votes
5answers
309 views

Isolating characters in a string

I'm struggling to find the right function in mathematica to isolate specific characters in a string. I have got a formula as string (I imported it from an excelfile) like this: y = 0.97*x1 + ...
4
votes
3answers
155 views

Reading binary strings from file as strings

I have a file that contains binary strings like 01011 00101 01011 I want to import the file to Mathematica as a list of strings, but ...
5
votes
3answers
213 views

neighbor swapping distance between two strings

Updated Problem Description I have a collection of strings $S$ that only contain two (or $m$ in general) kinds of elements: in this case C and D. For all $s\in S$, the length is the same, the number ...
2
votes
3answers
120 views

Counting instances where the two identical characters are at the same positions in two strings

Let $s_a$ and $s_b$ be two strings over a $q$-ary alphabet. For each character $(c_1,...c_q)$ in the alphabet, I'd like to return a pair of values $(r,k)$ where $r$ represents the count for the ...
2
votes
2answers
59 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 ...
7
votes
3answers
139 views

Converting StringJoin to StringForm inside Hold

Let's say I have a piece of code: Hold[{code1, "asdad " <> ToString[testa] <> " adsd " <> ToString[testb], code2}] (*MWE ofc*) ...
3
votes
1answer
122 views

Sorting an Array with words in different languages

Array consists of words of different languages. I need to sort elements in reverse alphabetical order and make a list of elements, which consist of english letters. Example of array which consist of ...
0
votes
1answer
26 views

Replacing character in position

I'm trying to use Mathematica to make some work on binary data, and I'm missing something. Consider the string "111". I want to flip the last bit to become ...
0
votes
0answers
13 views

Evaluating a String that is a Variable [duplicate]

I have a Variable assigned a value, say ImportantDocuments=1 How do I make N["ImportantDocuments"] evaluate to be 1 instead of ImportantDocuments I found that ...
0
votes
2answers
108 views

Swap first and last names in a list

Edited to fix an inconsistency in the given example data format. I'm trying to write a simple function to load in a csv list of names which is formatted as "Lastname Firstname Initial " and ...
4
votes
1answer
52 views

Converting StringForm output to a string produces unexpected results

I want to compose a string that contains newlines, so I tried the following: ...
0
votes
1answer
74 views

How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? [duplicate]

How to convert the expression '{a->a0, b->b0}' to the expression 'a=a0; b=b0'? I think this is a common question and do not know if someone has asked it before. Any help or suggestion will be ...
0
votes
1answer
73 views

How to replace characters which have alternate meanings in strings. This code works, but creates errors

The Problem: I often paste strings into Mathca which have many what I call "extender characters" --which may extend the character set." We know these have to be dealt with so Mathca can deal with ...
4
votes
2answers
100 views

Using Except with strings

Suppose that I have the following sample list, called list: list = {"bBb", "aAa", "aaa"}; Now suppose I want to select the ...
1
vote
3answers
76 views

Options in a StringReplace rule

case1 Options[f] = {"t" -> "0"}; f[___, OptionsPattern[]] := StringReplace["content", "t" :> OptionValue["t"]] f[] (* con0en0 *) case2 ...
5
votes
2answers
309 views

How to convert a string of number into real numbers without precision loss

I searched and did not find similar answers which can resolve the 'no precision loss' issue. A sample string is: ...
0
votes
1answer
59 views

expression in an string

I want to create several directories "dir_i" in a mother directory "home". and put an specific file in each directory ...
5
votes
6answers
249 views

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

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

How to represent very long integers with at-most-8-digit(base-10) short integers with * and +

I need an algorithm in Mathematica, which can represent any very long integer, prime or not, into the the product operation "*" and sum "+" forms by short integers (not more than 8 decimal digits). ...