Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: String patterns

  • To:
  • Subject: [mg10930] Re: String patterns
  • From: Paul Abbott <>
  • Date: Thu, 12 Feb 1998 20:16:13 -0500
  • Organization: University of Western Australia
  • References: <6brf6t$>

MJE wrote:

> How good is Mathematica at this kind of string manipultion and
> searching?

Here is a basic implementation:

In[1]:= string="I love Mathematica"; In[2]:= chars=Characters[string]
In[3]:= ToUpperCase[chars]

Select all upper case letters (and " ",".","-",":"):

In[4]:= Select[%,UpperCaseQ[#]||
      MemberQ[ToCharacterCode/@{" ",".","-",":"},ToCharacterCode[#]]&]

Form the trigraphs explicitly

In[5]:= trigraphs=Apply[StringJoin,Partition[%,3,1],{1}]

and compute the frequencies:

In[6]:=<<Statistics`DataManipulation` In[6]:=

MAT   2
VE    1
TIC   1
THE   1
OVE   1
 MA   1

There is probably a neat pattern-matching way of computing the
frequencies without constructing the trigraphs explicitly.

Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907  AUSTRALIA                   

            God IS a weakly left-handed dice player

  • Prev by Date: Re: NDSolve vs. DSolve
  • Next by Date: Re: Active Plots
  • Prev by thread: String patterns
  • Next by thread: Re: String patterns