Help with Regex (was Re: Switch, Case and wild-cards?)

Dr. Hawkins dochawk at gmail.com
Sun Dec 30 11:42:13 EST 2012


On Sunday, December 30, 2012, Richmond wrote:

>
>
> starts off by describing the blindingly obvious, and then tries to dress
> the whole thing up in a load of jargon so
> some fancy academic can draw a fat salary for understanding the blindingly
> obvious, and/or
> being capable of thinking in a straight line . . . but, hey, that seems to
> be a universal problem.
>

 if academics drew fat salaries, I would still be one.  I'm practicing law
again for the simple reason I need to make enough to send my own kids to
school . . .  but anyway . . .


> I have a line of text in "some funny language" that goes like this;
>
> 1aQngh1swnpQavh
>
> now there are the following considerations I have to deal with:
>
> 1. Every time I encounter a '1' it has to be shunted after the char it
> precedes.
> 2. Every time I encounter a 'Q' it has to be shunted before a char it
> comes after.
> 3. 1aQ (this is what is known as "the squirrel in the wood-pile" (and I'm
> sorry if I have offended any squirrels).
>
> Now a hierarchy of pattern recognition means I have to trap '1aQ'
> before I trap '1' and 'Q', because if I do things the other way round
> everything is going to be "stewed squirrel" to coin a phrase.


s/1\(.\)Q/magic_string_2\1magic_sting_1/g
s/1\(.\)/\11/g
s/\(.\)Q/1Q/g
s/magic_string_1/1/g
s/magic_string_2/Q/g

There's probably a syntax error or three in that (I don't need them very
often any more), and I suspect it can do it in one line, but I don't
remember conditionals.

The magic strings are just any string that would never occur; I usually use
ZZZ and GGG.

>
>

-- 
Richard E. Hawkins, Esq.
(702) 508-8462



More information about the use-livecode mailing list