9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "fwrm via 9fans" <9fans@9fans.net>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] A few more questions about sam
Date: Thu, 5 Aug 2021 20:22:00 -0400	[thread overview]
Message-ID: <16282093200.FCec64.804761@composer.9fans.topicbox.com> (raw)
In-Reply-To: <674DE2214EA337146FCDA7D4674815E7@prosimetrum.com>

[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2110 bytes --]

  reply	other threads:[~2021-08-06  0:22 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-05 16:12 revcomninos
2021-08-05 19:42 ` umbraticus
2021-08-06  0:22   ` fwrm via 9fans [this message]
2021-08-06  7:45     ` revcomninos
2021-08-06  9:20     ` revcomninos
2021-08-06 15:04 ` ori
2021-08-06 17:22   ` revcomninos
2021-08-06 19:20   ` Stuart Morrow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16282093200.FCec64.804761@composer.9fans.topicbox.com \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).