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

learn more… | top users | synonyms (2)

6
votes
2answers
143 views
6
votes
1answer
156 views

How to set up new types for pattern matching strings?

Consider the following toy example: I have a set of language sounds, which I partition into two exclusive subsets, consonants and vowels. I want to set up string patterns for e.g. ...
6
votes
2answers
190 views

How to choose variables from a list for a function and then use the solution in a subsequent function?

I am trying to calculate heating degree days and cooling degree days and output that information to a table. I am using mathematica's curated data to do this. In text this is what I would like to ...
6
votes
1answer
88 views

How does `LongestCommonSubsequence` work?

When I recently came across this posting about LongestCommonSubsequence I was curious about how the function worked. ...
6
votes
1answer
184 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 ...
5
votes
3answers
208 views

Thousands separator (comma) option for NumberString/StringCases?

I've been looking for a way to read numbers that have thousands separators in them: StringCases[" 1142.123 ", Whitespace ~~ NumberString ~~ Whitespace, 1] gives ...
5
votes
5answers
364 views

Extracting columns of text from a rectangular string

I have very large rectangular strings (on the order of 30-100 MB in size), which I import into Mathematica from text files using a command like ...
5
votes
3answers
278 views

Creating word histograms from lists of strings

Consider the following: ...
5
votes
3answers
110 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 ...
5
votes
2answers
169 views

Concatenate strings from different levels of list

After a lot of trouble I've finally come pretty close to what I want to do. I now have a list that looks like this: ...
5
votes
2answers
85 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 ...
5
votes
3answers
147 views

DateList's aggressive interpretation of TimeML duration codes

DateList "aggressively" interprets strings, such as "p72h": DateList["p72h"] gives ...
5
votes
1answer
157 views

import complete date string to mathematica

Based on an example from here I try to parse dates from a table including the time, but it fails. This is the modified example: ...
5
votes
2answers
236 views

Custom distance metric for agglomerative clustering in Mathematica

Is it possible to have a custom distance metric defined to determine the distance between two clusters in Agglomerative clustering in Mathematica? I have a 3 dimension data with string values along ...
4
votes
6answers
289 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"}?
4
votes
4answers
288 views

Creating lists from a string, separating words from numbers

Say I have a string that contains numbers and words, such as this one: string = "there are 1234 words and numbers 5678 in here $999"; How would I separate the ...
4
votes
3answers
98 views

Find the position of a string element, knowing only part of the string

I have a list, e.g.: list = {1, 2, 3, "Element 1", 4, 5, "Element 2", "Something else 1", "etcetera"} Now, I want all elements starting with ...
4
votes
2answers
88 views

How can I know if a pattern corresponds to a string pattern?

What would be the best way to detect if a pattern corresponds to a string pattern ? An invalid string pattern p would lead to an error in ...
4
votes
2answers
154 views

Split string into sub-strings of length n [duplicate]

Possible Duplicate: Partition string into chunks How can I split a string into sub strings of length n? For example I have a string "ABCDEabcde1234" ...
4
votes
1answer
48 views

WordBoundary issue in StringReplace

Why does the following StringReplace pattern match: ...
4
votes
1answer
72 views

Extracting text from cells, preserving non-ASCII characters

Consider the following setup, based on this answer by WReach: ...
4
votes
1answer
78 views

Strange behavior of DateList when converting string

DateList experiences some strange behavior which i cannot explain. This code works fine: ...
4
votes
1answer
176 views

Defining a string based sort function

I'm having a bit of trouble figuring out the right Sort syntax to use on a list of lists. Consider the following list: ...
3
votes
3answers
192 views

Converting a string containing whitespace-delimited numbers to a list of numbers

Suppose I have a string str that contains only whitespace-delimited real numbers: ...
3
votes
3answers
90 views

Using NumberString, DigitCharacter, or a similar directive to find all string representations of integers in a string

I have a text file containing many, many lines of text like test in the following: ...
3
votes
5answers
221 views

How to extract strings from the list with an additional condition on previous elements?

There are a long list of strings $s$ and two lists of substrings $s1$ and $s2$. I want to take all elements of $s$ which contain a substring from $s2$ and such that before it on no more than $n$ ...
3
votes
2answers
165 views

Highlighting text with StringReplacePart but also using Style, Subscript

For a Natural Language Processing analysis task it's desirable to highlight a text string programmatically according to XML tags that reference specific words or phrases. The XML tags specify the ...
3
votes
2answers
98 views

Import[] exception possibly caused by ToString[] behaviour which I cannot explain

Let me just start by pointing out I'm a new StackExchange user as well as a new Mathematica user (started today!) I mention this as a context to my ineptitude :) I am attempting to read through a ...
3
votes
3answers
328 views

Parameters in plot titles

My issue is how to mix strings with variables, specifically in the context of PlotLabel: I can put a string as my plot title, and I can also put a variable as a ...
3
votes
1answer
95 views

String replacement to make the TeXForm output beautiful

This question is inspired by this question: How to convert the symbol $d$ in Integrate into $\mathrm{d}$?. Although it’s not a big problem, the TeXForm can be ...
3
votes
0answers
82 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 ...
2
votes
4answers
129 views

How to write a function to remove comments from a .m source file preserving formatting such as line wrapping reasonably?

How to write a function to remove comments from a .m source file preserving formatting such as line wrapping reasonably? This means if I have ...
2
votes
3answers
224 views

How to extract a consecutive list of substring from a string?

Given a list of strings: data = { "2894;Hot Pink;53:09:44;1449714", "17456;Dark Cyan;19:06:42;6929227", "5147;Lime;54:11:55;5247632" } (Words are separated by ...
2
votes
4answers
139 views

Remove anything between () except for ; in a string

A simple question but I can't find the answer. I'm scanning a huge pile of mails and would like to get rid of anything between () in the email adresses since this normally contains just info that ...
2
votes
1answer
90 views

Confused behavior using Dispatch to sort one list relative to another

I have a need to sort the entries of one list into the same sequence as the entries in a reference list. Because I have rather large lists involving strings, I'm trying to use Dispatch to accomplish ...
2
votes
1answer
79 views

ToString in a function

f[x2_] = ToExpression[StringTake[ToString[x2], -1]] x2; f[a3] (*Out: 2 a3*) I expected the output to be 3 a3, but apparently ...
2
votes
2answers
142 views

Formatting text through pattern matching

I am trying to format some text based on some patterns. ...
2
votes
2answers
89 views
1
vote
2answers
108 views

Why do I get two different results from StringLength?

I spent a reasonable amount of time to find the origin of an error in a larger code segment. ...
1
vote
2answers
48 views

How to convert TableForm to proper LaTex and why is “\” not replaced by StringReplace?

I'm trying to optimize the teXForm output of a table because the standard output ist not satisfying: ...
1
vote
2answers
80 views

Image processing - How can I apply an operation to several images at once?

I imported pictures into Mathematica, and used names for them that follow the easy scheme "name" string joined with an integer, ranging from 14 to 20. Printing these images on screen works nicely: ...
1
vote
2answers
166 views

Faster way to convert real strings into numbers [duplicate]

Working with big files, I have to convert some numbers that are in string format into real MMA numbers. I know that I can use ToExpression but it's slow when ...
1
vote
2answers
108 views

Finding strings in Web Code [duplicate]

I haven't found an answer that solves my problem, although I think it's actually a simple one. It seems hard to me because I don't have a lot of experience with string patterns. I have a Web Code ...
1
vote
1answer
148 views

Renaming files of form FileName(i).csv to NewNamej(k).csv where j increments and k resets to 1 when there is a jump in i?

Edit up top: The accepted answer works splendidly except I had to add //ToExpression to the end of the definition of ns given by ...
0
votes
2answers
81 views

help with StringJoin [duplicate]

dollarWon := 100 "(" <> Style["$" <> ToString[dollarWon], If[dollarWon >= 0, Darker[Green], Red]] <> ")" I am getting an error: String ...
0
votes
1answer
133 views

StringJoin/FileNameJoin doesn't quite work in script

My mathematica script is as follows: ...
0
votes
3answers
120 views

How to export a header before the data in the result file?

I would like to export a phrase to my result data as a heading. I'm exporting the data correctly with Export["file.dat", table]. But I'm doing several ...
0
votes
1answer
111 views

How do I construct a “named character” programmatically?

Why am I getting the error Syntax::sntunc: Unicode longname in the string is unterminated. from the following? ...
0
votes
1answer
58 views

Construct file names using a number and a string prefix [duplicate]

I'm trying to append filenames with Mathematica, and cannot do it. The output of my calculation are two lists : X and Y, ...
0
votes
0answers
76 views

How to highlight a string pattern? [duplicate]

This is an example in the help pages (Working with patterns: Highlight Patterns): ...