From aa3dff098c511492a958cb05013c37309477de84 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 2 Apr 2019 12:46:23 +0200 Subject: [PATCH] docs/string: Add paragraph on comparison with unix tools [ci skip] --- sphinx_doc_src/cmds/string.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sphinx_doc_src/cmds/string.rst b/sphinx_doc_src/cmds/string.rst index b7fa6752c..13e3608b6 100644 --- a/sphinx_doc_src/cmds/string.rst +++ b/sphinx_doc_src/cmds/string.rst @@ -226,6 +226,21 @@ And some other things: - ``^`` is the start of the string or line, ``$`` the end. - ``|`` is "alternation", i.e. the "or". +Comparison to other tools +------------------------- + +Most operations ``string`` supports can also be done by external tools. Some of these include ``grep``, ``sed`` and ``cut``. + +If you are familiar with these, it is useful to know how ``string`` differs from them. + +In contrast to these classics, ``string`` reads input either from stdin or as arguments. ``string`` also does not deal with files, so it requires redirections to be used with them. + +In contrast to ``grep``, ``string``\ s `match` and `replace` default to glob-mode. If set to regex-mode, they use PCRE regular expressions, which is comparable to ``grep``\ s `-P` option. `match` defaults to printing just the match, which is like ``grep`` with `-o` (use `--entire` to enable grep-like behavior). + +Like ``sed``\ s `s/` command, ``string replace`` still prints strings that don't match. ``sed``\ s `-n` in combination with a `/p` modifier or command is like ``string replace -f``. + +``string split somedelimiter`` is a replacement for ``tr somedeliminter \n`. + Examples --------