Discussion:
[9fans] sam command language question
(too old to reply)
Steve Simon
2012-08-20 11:12:19 UTC
Permalink
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
2012-08-20 11:55:25 UTC
Permalink
Post by Steve Simon
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.
,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)

2) I will think about your own code later.

Ruda
Rudolf Sykora
2012-08-20 12:05:31 UTC
Permalink
Post by Steve Simon
,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
2012-08-20 12:15:11 UTC
Permalink
Post by Steve Simon
,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
2012-08-20 12:28:31 UTC
Permalink
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
2012-08-20 13:21:12 UTC
Permalink
Post by Steve Simon
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.
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
words, then capitalizes the first letter of each word.

Ruda

Loading...