此 sed 表达式将输入字符串转换为两行输出字符串。两条输出线中的每一条都由来自输入的子字符串组成。第一行需要转换为大写:
s:random_stuff\(choice1\|choice2\){\([^}]*\)}:\U\1\n\2:
目的是转换
random_stuff_choice1{This is a sentence that MAY contain AnyThing}
random_stuff_choice2{This is another similar sentence}
进入
CHOICE1
This is a sentence that MAY contain AnyThing
CHOICE2
This is another similar sentence
我遇到的问题是 \U 适用于它后面的所有内容,因此第二行也是大写的。是否可以使 \U 仅适用于第一场比赛?