Re: refering to a long pattern by a variable
- To: mathgroup at smc.vnet.net
- Subject: [mg57729] Re: refering to a long pattern by a variable
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Tue, 7 Jun 2005 02:03:30 -0400 (EDT)
- Organization: Uni Leipzig
- References: <d811a4$cb7$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, txt = "abcbacabzzcz"; pat = Characters["bc"] pat2 = StringExpression @@ (pat /. "b" :> Sequence @@ {"b", ___}) StringCases[txt, ShortestMatch[pat2], Overlaps -> False] ?? Regards Jens <marloo3 at mail15.com> schrieb im Newsbeitrag news:d811a4$cb7$1 at smc.vnet.net... > hello > i wish if i could refer to a long pattren by > just a variable, > suppose the: > txt="abcbacabzzcz"; > and the pattern to search is "b"~~___~~"c" > StringCases[txt, ShortestMatch["b" ~~ ___ ~~ > "c"], Overlaps -> False] > Out[]={bc, bac, bzzc} > ok, i hope there is a way to supply just the : > pat=Characters["bc"]; > and some procedure will make the "b" ~~ ___ ~~ > "c" from the above pat variable > and assign this pattern to pat2 variable so we > just write: > StringCases[txt, > ShortestMatch[pat2], Overlaps -> False] > to give the output > Out[]={bc, bac, bzzc} > i have tried it by StringJoin but it does not > work. > thanks > >