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

learn more… | top users | synonyms (2)

10
votes
3answers
261 views

balanced Shortest[] and string-patterns

The pattern Shortest["A"~~__~~"B"] is oriented : It assumes the text is read from left to right and it takes the text between the first "A" and the next "B". Any ...
10
votes
2answers
299 views

Mathematica Typing Effect

Here is a Typing Effect in javascript. I could only implement a very simple one: ...
10
votes
2answers
150 views

Unexpected result from StringReplace

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

StringReplace, ReplaceAll and Rule interact in a bizarre way

I have the following pair of things: ClearAll[foo, labeledFoo]; labeledFoo = {"FooBarBazQuux", foo}; This works like you'd expect: ...
10
votes
1answer
744 views

Mathematica equivalent of regex '\w{2,3}'

It beats me to write the Mathematica pattern equivalent to the regex: \w{2,3} Any ideas?
10
votes
2answers
676 views

How to get string representation (like repr in Python)

I have a string variable. I want to obtain another string which contains the representation of the string variable content itself. s = "a \n b" I need to get a ...
9
votes
5answers
783 views

convert long string to integer list

at first, i would like to thank all the people here. i'm working with mathematica for half a year now and always found great advice and tricks. now, i came up with a problem i couldn't find a ...
9
votes
2answers
253 views

Behavior of ImportString in Mathematica

I tried the following commands ...
9
votes
4answers
466 views

How does string interpolation work in Mathematica

I've noticed that Mathematica 8 seems to have some kind of string interpolation feature, but I couldn't find any documentation on it and I can't figure out how it works. For example, if I enter ...
9
votes
2answers
437 views

Keeping Quotation Marks in Output

I am running into the following seemingly simple problem. I have this code: testphrase="i love you"; input=ToLowerCase[StringSplit[testphrase, Whitespace]] It ...
9
votes
1answer
128 views

Named string patterns in Alternatives, why does it depend on order?

When using the same name for part of patterns inside Alternatives how come it behaves differently for strings than in normal patterns? ...
9
votes
1answer
249 views

Creating a version of SequenceAlignment that accepts patterns

SequenceAlignment seems like a function that is not (yet?) fully integrated into Mathematica. I want a function that accepts general patterns instead. I ...
8
votes
2answers
2k views

Convert a string to hex number?

How can I convert a string containing a hex number such as "6b" to a hex digit that mathematica can use to do math with? I have tried using ...
8
votes
3answers
380 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: ...
8
votes
1answer
140 views

CSS Selectors for Symbolic XML

Symbolic XML is a convenient way of managing XML in Mathematica, at least for casual use or small tasks. Here and elsewhere you can find examples of XML handling in Mathematica, including XSLT/XPath ...
8
votes
2answers
119 views

Convert recursive RegularExpression to StringExpression?

Consider the following expression for matching balanced brackets: ...
8
votes
2answers
543 views

A femme is a wife is a Frau

As can be seen from LanguageData["Properties"] // Multicolumn Mathematica's translation capabilities seem to be very limited. It can translate month names, ...
7
votes
3answers
323 views

Unencoding encoded URLs in a function

Is there a built-in function for decoding encoded URLs in Mathematica? I would like to convert an encoded URL, for example ...
7
votes
5answers
389 views

Splitting strings at lower case characters and numbers

I'm trying to split the strings of chemicals into their elements and numbers. See this example "Fe3O4" will be split into ...
7
votes
5answers
258 views

String replacement question

If you have a string string="<ALK>ene" and I have a list alk={"meth", "eth", "prop", "but", "pent"}, what function ...
7
votes
3answers
606 views

Creating word histograms from lists of strings

Consider the following: ...
7
votes
4answers
434 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 ...
7
votes
1answer
164 views

Understanding `Paste` and how to get a string from the Clipboard to use with `ImportString`

Trying to work on this question I got distracted by my first naive attempt of copying the data and then typing dat = ImportString[Paste[], "Table"] ...
7
votes
3answers
174 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*) ...
7
votes
2answers
193 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 ...
7
votes
1answer
2k views

What pattern will match accented letters in a regular expression?

How should I modify the following such that the accented letter É is matched and the expression returns True? ...
7
votes
2answers
196 views
7
votes
3answers
231 views

How to turn a set of strings which represent a list into a 2D list

I have a set of data read in from a larger CSV file. I want it to match the format I have from another analysis. It is structured as a series of strings with letters and numbers Here it is copy-pasted ...
7
votes
1answer
137 views

LetterCharacter for Cyrillic symbols

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

Revert FullForm-ed text to prettyprinted

Sometimes strings in a notebook/package file end up garbled due to some unknown/unintentional conversion of the expression/cell/notebook. I could not find a way to revert such unreadable text to its ...
6
votes
4answers
286 views

Where can I take a pool of words from?

Dear Community members, I am thinking about an interactive machine to teach a school child to write difficult words correctly. As a first step I need a collection of words. I will select a pool of ...
6
votes
6answers
1k views

Convert a string into a list of numbers

I got the following problem I don't know how to solve or if it's at all possible to solve(I'm quite new to Mathematica and don't have an IT background, so please explain slowly if possible:)) I'm ...
6
votes
3answers
291 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: ...
6
votes
2answers
492 views

How to overload System`StringJoin to automatically use ToString on arguments?

I am using an overloaded version of the StringJoin function since years now, without any problem, as I've invested a lot of time and effort earlier to make its ...
6
votes
4answers
666 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 ...
6
votes
4answers
297 views

Is there a more Mathematica-y way to label these plots?

I am studying an infinite square well in the context of quantum mechanics. ...
6
votes
3answers
1k views

print the name of the variable in a list without evaluation

a := az + 1 b := bz + 5 list := {a, b} I'd like mathematica to print a = az + 1 b = bz + 5 so basically it needs to first ...
6
votes
3answers
208 views

Problem with WordBoundary in string patterns

I am trying to extract from a string all words that end with "-man", but the problem is that WordBoundary does not seem to work as it returns whole string ignoring ...
6
votes
4answers
177 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 ...
6
votes
2answers
192 views

How to Clear variables represented as a list of strings?

Say I have a string list called fullpara fullpara={"width", "long", "line", "distance"} And there are corresponding variables ...
6
votes
3answers
300 views

Importing and manipulating strings - time data

I have a list of time durations, which are strings of the form: "hh:mm:ss". Here's a sample for you to play with: ...
6
votes
2answers
156 views

Why is StringMatchQ[“IP1”, “IP”] returning False?

Maybe there is a knot in my head, but I would expect that StringMatchQ["IP1", "IP"] should return True (which it does not) ...
6
votes
3answers
181 views

Isolating string characters

I have the following string: ...
6
votes
3answers
251 views

String templating

I am pretty new to string processing in Mathematica. But I'm having some problems in doing simple string template filling to my mind elegantly. For example when doing export for my answer here, one of ...
6
votes
2answers
202 views

How to count words in a Greek text

I want to perform a simple analysis of some Greek text: collect the different words used and count their frequency. It seems that some of the built-in commands do not work well with Greek letters. For ...
6
votes
1answer
186 views

Returning computable numbers from WolframAlpha

WolframAlpha["Apple company revenue", {{"Result", 1}, "Plaintext"}] Desired output 182800000000 ...
6
votes
2answers
1k 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: ...
6
votes
2answers
263 views

Formatting text through pattern matching

I am trying to format some text based on some patterns. ...
6
votes
1answer
320 views

Interpreting text entry and splitting it in a Manipulate text field?

I have the following program that plots the number of trigram appearances across a corpus of textual information between 1964 and 1989 (apologies for the messy code): ...
6
votes
1answer
239 views

Match sequence of zero or more characters except a given character

This looks like it should be simple: I want to match an "i" followed by an "o" with an arbitrary (possibly zero-length) sequence of characters in between, unless that sequence also contains an "i". ...