Regex-based matching and sustitution with nano?

后端 未结 3 1639
时光取名叫无心
时光取名叫无心 2020-12-17 09:33

I am aware of nano\'s search and replace functionality, but is it capable of using regular expressions for matching and substitution (particularly substitutions

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 10:10

    The regular expression format / notation for nano use "Extended Regular Expression", i.e. POSIX Extended Regular Expression, which is used by egrep and sed -r, this include metacharacters ., [ and ], ^, $, (, ), \1 to \9, *, { and }, ?, +, |, and character classes like [:alnum:], [:alpha:], [:cntrl:], [:digit:], [:graph:], [:lower:], [:print:], [:punct:], [:space:], [:upper:], and [:xdigit:].

    For more complete documentation you can see manual page, man 7 regex in Linux or man 7 re_format in OS X. This page may give you same information as well: https://en.wikipedia.org/wiki/Regular_expression#POSIX_basic_and_extended

    Unfortunately in nano there seems to be no way to match anything that span across multiple lines.

提交回复
热议问题