4) In ed/awk/grep/etc... regexp is used to "select" *the lines containing it* 
and do stuff, in sam however it's used to describe the shape of string(s) 
themselves you want to "select" (with x and y commands). It doesn't have the 
concept of a line. Your selection can be less than a line, or you can select 
multiple strings that happen to be in different lines. Or multiple lines.

For example, consider this string:
hello "test" bye
"hello" again

The command ,x/".+"/ would select every string that begins with a double quote, 
has one character or more after that, and ends with a double quote. If we 
wanted to select only the characters inside double quotes, we could reject the 
double quote character by adding the command y/"/ to the previous one. Or we 
can also only select the quotes by adding x/"/ instead, if we wanted to change 
double quotes (that surround one or more characters) to single quotes we could 
do: ,x/".+"/ x/"/ c/'/ or to capitalize all letters inside quotes (with the 
unix tool tr(1)) we could do: ,x/".+"/ y/"/ | tr [:lower:] [:upper:]

You can do interesting things with x and y when you combine them with the 
conditionals: g and v.
------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T3107cd3bc536dc63-M6657add7fd6d31ba8f447d79
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to