       RE: Working with strings

• To: mathgroup at smc.vnet.net
• Subject: [mg31965] RE: [mg31940] Working with strings
• From: "tgarza01 at prodigy.net.mx" <tgarza01 at prodigy.net.mx>
• Date: Fri, 14 Dec 2001 04:21:33 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Something like this,perhaps?

In:=
myString = ToString /@ {S, T, M, x, R, K, P, G}
Out=
{"S", "T", "M", "x", "R", "K", "P", "G"}
In:=
posx = Flatten[Position[LowerCaseQ /@ myString, True]][[
1]]
Out=
4
In:=
string1 = Take[myString, posx - 1]
Out=
{"S", "T", "M"}
In:=
string2 = Take[myString, posx - Length[myString]]
Out=
{"R", "K", "P", "G"}
In:=
Flatten[Outer[List, string1, string2], 1] /.
{a_String, b_String} -> StringJoin[a,
myString[[posx]], b]
Out=
{"SxR", "SxK", "SxP", "SxG", "TxR", "TxK", "TxP", "TxG",
"MxR", "MxK", "MxP", "MxG"}

Tomas Garza
Mexico City

Original Message:
-----------------
From:  bghiggins at ucdavis.edu (Brian Higgins)
To: mathgroup at smc.vnet.net
Subject: [mg31965] [mg31940] Working with strings

I have a list of string characters that I would like to group in a
particular way. The list has the following structure:

{n UpperCase Characters, x, m UpperCase Characters}

Here is an example:

myString={"S", "T", "M", "x", "R", "K", "P", "G"}

Now I would like to form the following groupings:

{"SxR", "SxK", "SxP", "SxG", "TxR", "TxK", "TxP", "TxG", "MxR", "MxK",
"MxP", \
"MxG"}

A brute force way of doing this is

subString[n_] := Split[myString, UpperCaseQ[#2] && UpperCaseQ[#1]
&][[n]];

Flatten[Outer[StringJoin, Outer[StringJoin, subString,
subString],
subString]]

Does anyone have any elegant way of doing this with perhaps using
replacement rules?

Thanks much,

Brian

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

```

• Prev by Date: RE: Working with strings
• Next by Date: Re: Re: Solve[] for equations?
• Previous by thread: RE: Working with strings
• Next by thread: package from developer's conference