Steve Simon | 20 Aug 2012 13:12
Favicon

sam command language question

Tis the season for exotic sam command language questions,
though mine is not that exotic.

I want to edit some xml (yes I know) and capitalise all the labels
in it. I only want to do this once so I don't care that it will
envoke tr thousands of times and take a minuite or so.

This is what I tried:

	,x/label="[^"]+"/ {
		x/ [a-z]/ | tr a-z A-Z
	}

sadly the inner 'x' searches onward in the file and not in
the selection (dot) generated by the outer 'x'.

I tried a few more random commands but nothing very sensible,
anyone any ideas?

Seems somthing that should be easy...

-Steve

Rudolf Sykora | 20 Aug 2012 13:55
Picon

Re: sam command language question

On 20 August 2012 13:12, Steve Simon <steve <at> quintile.net> wrote:
> Tis the season for exotic sam command language questions,
> though mine is not that exotic.
>
> I want to edit some xml (yes I know) and capitalise all the labels
> in it. I only want to do this once so I don't care that it will
> envoke tr thousands of times and take a minuite or so.
>
> This is what I tried:
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> sadly the inner 'x' searches onward in the file and not in
> the selection (dot) generated by the outer 'x'.
>
> I tried a few more random commands but nothing very sensible,
> anyone any ideas?
>
> Seems somthing that should be easy...
>
> -Steve
>

1) what's wrong with
,x/label="[^"]+"/ | tr a-z A-Z
?
(besides that it also capitalizes label -> LABEL; but this would do
your code too)
(Continue reading)

Rudolf Sykora | 20 Aug 2012 14:05
Picon

Re: sam command language question

On 20 August 2012 13:12, Steve Simon <steve <at> quintile.net> wrote:
> This is what I tried:
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> sadly the inner 'x' searches onward in the file and not in
> the selection (dot) generated by the outer 'x'.

I do not see the reported behaviour. For me it searches through the
dot prepared by the first 'x' command... Thanks to the 'space'
character in the second 'x' it however capitalizes only the first
letter of any word in paranthesis which has a space in front of
itself.

Ruda

Rudolf Sykora | 20 Aug 2012 14:15
Picon

Re: sam command language question

On 20 August 2012 13:12, Steve Simon <steve <at> quintile.net> wrote:
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }

Perhaps, also, I haven't correctly understood what you are after. If
what I wrote doesn't solve the problem, an example of what is needed
would help.

Ruda

Steve Simon | 20 Aug 2012 14:25
Favicon

Re: sam command language question

I am confused, and appologise to all for the noise.

	,x/label="[^"]+"/ {
		x/ [a-z]/ | tr a-z A-Z
	}

does exactly what I wanted, I don't understand why in my toy tests it
didn't appear to work, probably a typo.

for the record I was tring to do this:

	label="Hello"
->
	label="Hello"      (i.e. unchanged)

	label="Hello world and other planets"
->
	label="Hello World And Other Planets"

-Steve

Rudolf Sykora | 20 Aug 2012 15:21
Picon

Re: sam command language question

On 20 August 2012 14:25, Steve Simon <steve <at> quintile.net> wrote:
> I am confused, and appologise to all for the noise.
>
>         ,x/label="[^"]+"/ {
>                 x/ [a-z]/ | tr a-z A-Z
>         }
>
> does exactly what I wanted, I don't understand why in my toy tests it
> didn't appear to work, probably a typo.
>
> for the record I was tring to do this:
>
>         label="Hello"
> ->
>         label="Hello"      (i.e. unchanged)
>
>         label="Hello world and other planets"
> ->
>         label="Hello World And Other Planets"
>
> -Steve
>

You could also use something like the following. It would, compared to
your code, also capitalize the very first word in the quotation marks
(your Hello, if it were hello).

,x/label="[^"]+"/ .-#0+#7,.+#0-#1 y/ / .-#0,.-#0+#1 | tr a-z A-Z

It finds the label="stuff", then limits to stuff, then breaks into
(Continue reading)


Gmane