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

learn more… | top users | synonyms (2)

2
votes
2answers
294 views
7
votes
3answers
276 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 ...
14
votes
2answers
289 views

Haiku Extractor

Inspired by the cool Tumblr Haiku Times that searches for accidental haiku in New York Times articles, I tried my hand at implementing such a search in Mathematica for my own text samples. I'm still ...
1
vote
2answers
122 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 ...
0
votes
1answer
162 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, ...
-4
votes
2answers
174 views

how can i convert data into string format? [duplicate]

I have nested-lists in number format,like data={{1,2,3},{2,{3,4,50}},{4,5,6},{3,{3,{5,6}}}} I want to convert each number into ...
5
votes
1answer
144 views

Extracting text from cells, preserving non-ASCII characters

Consider the following setup, based on this answer by WReach: ...
2
votes
2answers
1k 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
117 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. ...
0
votes
3answers
362 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 ...
9
votes
3answers
236 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 ...
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? ...
5
votes
2answers
260 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: ...
2
votes
1answer
107 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 ...
3
votes
5answers
319 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 ...
1
vote
1answer
234 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 ...
10
votes
9answers
2k views

How do I extract a number from a string?

I want to extract the number from an alphanumeric string. This is what I tried: StringTake["thiru3", {6, 6}] The result I got is ...
2
votes
3answers
354 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 ...
3
votes
0answers
118 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 ...
4
votes
2answers
98 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 ...
10
votes
2answers
291 views

Mathematica Typing Effect

Here is a Typing Effect in javascript. I could only implement a very simple one: ...
4
votes
1answer
112 views

Strange behavior of DateList when converting string

DateList experiences some strange behavior which i cannot explain. This code works fine: ...
6
votes
4answers
273 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 ...
0
votes
1answer
155 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? ...
9
votes
5answers
650 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
3answers
413 views

How to remove accents from text?

I would like to know how I can remove accents from a string. For example, how can I transform "string test áéíóú" into ...
3
votes
2answers
173 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 ...
4
votes
1answer
63 views

WordBoundary issue in StringReplace

Why does the following StringReplace pattern match: ...
34
votes
3answers
1k views

Visualizing the difference between two sequences (strings)

I'm trying to develop a way of comparing two sequences (probably originally text, such as text writing or source code, possibly converted to lists). As a familiar example, consider the revisions ...
14
votes
6answers
456 views

Splitting a list by specifying section headers

I have a list of strings called mylist: mylist = {"[a]", "a", "a", "[b]", "b", "b", "[ c ]", "c", "c"}; I would like to split ...
2
votes
1answer
115 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 ...
4
votes
3answers
1k 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 ...
4
votes
2answers
458 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" ...
6
votes
3answers
238 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: ...
8
votes
2answers
1k 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 ...
22
votes
3answers
1k views

How to join two Style[]d strings

Does anyone know whether it is possible to combine\join two styled strings? That is, while the following code works fine: omega = "text"; omega<>omega ...
3
votes
3answers
443 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: ...
0
votes
1answer
324 views

StringJoin/FileNameJoin doesn't quite work in script

My mathematica script is as follows: ...
6
votes
2answers
144 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) ...
23
votes
4answers
1k views

What is the fastest way to count square-free words?

Background A word is a string of letters in an alphabet. A square-free word has no adjacent repeating substring. For example, (in the ternary alphabet of {0,1,2}) the words 00, 012121, and 0212012021 ...
5
votes
5answers
443 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 ...
14
votes
3answers
438 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 ...
7
votes
3answers
504 views

Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
3
votes
3answers
118 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
302 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$ ...
10
votes
7answers
210 views

DateList coupled with String Operations

Through some webscraping, I have the following list: ...
5
votes
3answers
166 views

DateList's aggressive interpretation of TimeML duration codes

DateList "aggressively" interprets strings, such as "p72h": DateList["p72h"] gives ...
5
votes
1answer
263 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: ...
4
votes
4answers
508 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 ...
5
votes
3answers
285 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 ...