Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Questions on the manipulation of String objects in Mathematica, and the functions used for these manipulations.
9
votes
Accepted
Replacing doubled letter with that letter plus a code
StringReplace["hello, this is silly", x_ ~~ x_ -> x ~~ "X"]
"helXo, this is silXy"
8
votes
Accepted
StringMatchQ fails using Alternatives with complex pattern
The problem arises from naming the inner sub-patterns in your two pattern definitions with the same identifier. When you combine the patterns with Alternatives, you then have a pattern with two sub-pa …
8
votes
Accepted
Finding the number of syllables in a string of text
I think you should look at WordData.
WordData["hyphenation", "Hyphenation"]
{"hy", "phen", "a", "tion"}
The definition of what is a syllable in English is tricky. The algorithm used by WordDat …
7
votes
How do I insert a calculated value into a text cell?
f[x_] := x^3 + x^2 + 1
Create a text cell containing:
$\qquad$The value of this function at 7 is N[f[7]]
Select N[f[7]] in the cell
Choose Evaluate in Place from the Evaluation menu or that operat …
6
votes
Built-in way to convert Integer to Ordinal String
A brute force but very simple approach (no undocumented functions needed) that I think will work with any version of Mathematica.
ordinalRule[n_Integer /; Mod[n, 100] == 11] := generalRule[n]
ordinal …
6
votes
A possible bug about WordCharacter on CJK characters
This is a pretty ugly hack, but maybe it will inspire you to something better.
leastCJK = ToCharacterCode["⺀"][[1]];
StringMatchQ[#, _?(ToCharacterCode[#][[1]] < leastCJK &)] & /@
{"a", "1", ".", …
6
votes
Accepted
Deleting certain elements of a list
Although I very much in favor of aardvark2012's answer using Pick, I would like to note that this can done with good old Table.
data = {{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"z", "y"}, {" …
6
votes
Deleting certain integers from string list
The following works for your example. But I am not sure that it will work for you if your example is not descriptive enough for some more general situation you have in mind.
lis = {"a", "1", "b", "2" …
6
votes
Using Position to get position of string of a list of strings
Position has some unusual defaults. As ref/Position says
The default level specification for Position is {0,Infinity}, with Heads->True.
So it is a little tricky to use StringContainsQ directly …
6
votes
Accepted
Converting StringForm output to a string produces unexpected results
I ran into this problem in 2009. I submitted it to WRI technical support. This is the reply I received.
After going through your notebook, I believe that what you observed is the
expected behavi …
5
votes
Problem with WordBoundary in string patterns
There is a reason to use WordBoundary, but your example sentence doesn't bring it out. Consider
mystring = "I am a demanding fan of Superman, Spiderman and Batman.";
StringCases[mystring, LetterChar …
5
votes
Using FromDigits to convert number strings to numbers
It looks to me that when you copied you copied the plain text form not the input form of the list of strings representing your hexadecimal numbers. Normally, copying form output cells gives the input …
5
votes
Accepted
Match groups in regular expressions
This is a minor variation on the last example in the Examples > Generalizations & Extensions section of RegularExpression,
StringCases["big bad wolf", RegularExpression["(.*) .* (.*)"] -> {"$1", "$2" …
4
votes
Finding strings in Web Code
You can use Shortest if the sub-strings of the form <td, class=test, >...</td> don't contain nested sub-strings of the form <td, class=test, > or </td>. If they do, follow this link.
v = "...<td, cl …
4
votes
Generating a list of file names
It seems that a simple modification of your code will work.
fileList[prefix_String, m_Integer, n_Integer] :=
With[{dash = "-"},
prefix <> dash <> ToString[#] <> dash <> ToString[n] <> ".asc"] …