我如何在尴尬的记录分隔符中设置符号

发布于 2025-01-29 06:33:01 字数 442 浏览 2 评论 0原文

我如何将符号包括在尴尬的记录分离器中。我知道这样的基本语法:

awk 'BEGIN{RS="[:.!]"}{if (tolower($0) ~ "$" ) print $0 }'

它将基于单独的记录将单行分开! 。而且:但是我也想包括诸如绿色复选标记的符号此。我很难理解语法,所以我把它放在似乎

awk 'BEGIN{RS="[:.!\u2705]"}{if (tolower($0) ~ "$" ) print $0 }'

不起作用的情况下。

样本输入是这样:

✅  Team collaboration  ✅  Project organisation✅  SSO support✅  API Access✅  Priority Support 

How do I include symbols into the record separator of awk. I know the basic syntax like this:

awk 'BEGIN{RS="[:.!]"}{if (tolower($0) ~ "
quot; ) print $0 }'

which will separate a single line into separate records based on ! . and : but I also want to include symbols like a green checkmark this . I am having trouble understanding the syntax, so I put it in like this

awk 'BEGIN{RS="[:.!\u2705]"}{if (tolower($0) ~ "
quot; ) print $0 }'

which doesnt seem to work.

Sample input is this:

✅  Team collaboration  ✅  Project organisation✅  SSO support✅  API Access✅  Priority Support 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸伞微斜 2025-02-05 06:33:01

您需要与交替运算符(|)一起使用REGEX,因为您要使用的字符由三个独立的UTF8代码单位组成:e29c 9c < /代码>和85

您可以使用

awk 'BEGIN{RS="[:.!]|\xE2\x9C\x85"} tolower($0) ~ "$"'

在线演示

#!/bin/bash
s='✅ Team collaboration ✅ Project organisation✅ SSO support✅ API Access✅ Priority Support'
awk 'BEGIN{RS="[:.!]|\xE2\x9C\x85"} tolower($0) ~ "$"' <<< "$s"

output:output:


 Team collaboration 
 Project organisation
 SSO support
 API Access
 Priority Support

请注意,打印$ 0是默认值>动作,无需明确使用它。

You need to use a regex with an alternation operator (|) because the character you want to split with consists of three separate UTF8 code units: E2, 9C and 85.

You can use

awk 'BEGIN{RS="[:.!]|\xE2\x9C\x85"} tolower($0) ~ "
quot;'

See the online demo:

#!/bin/bash
s='✅ Team collaboration ✅ Project organisation✅ SSO support✅ API Access✅ Priority Support'
awk 'BEGIN{RS="[:.!]|\xE2\x9C\x85"} tolower($0) ~ "
quot;' <<< "$s"

Output:


 Team collaboration 
 Project organisation
 SSO support
 API Access
 Priority Support

Note that print $0 is a default action, no need to use it explicitly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文