使用Notepad ++或其他工具,我希望从500P以上的PHP Echo调用中删除括号,以便从
// function testConcrete(key: "a" | "b" | "c"): void
到
df_CK <- data.frame(id = c(1:36), ck = c(121, 82, 100, 151, 68, 58, 95, 145, 64, 199, 101, 163,
84, 57, 139, 60, 78, 94, 119, 104, 110, 113, 118, 203, 62, 83, 67, 93, 92, 110, 25, 123, 70, 48, 95, 42))
ggplot(df_CK, aes(x = ck, y = ..density..)) +
geom_histogram(breaks = c(20, 40, 60, 80, 100, 120, 140, 160, 200, 220), fill = "coral1", colour = "grey60", size = .2) +
theme(plot.title = element_text(size = 5, face = "bold", hjust = 0.5)) +
theme_classic() +
theme_bw(base_line_size = 0, base_rect_size = 0.25, base_size = 6) +
ylab("Densidade") +
scale_x_continuous(limits = c(0, 216), breaks = seq(0, 216, 9))
# geom_text(aes(x = ck, label = ..prop.., y = ..density..),
# position = position_dodge(width = .5), vjust = -0.5, size = 2)
我曾尝试在正则表达式中使用echo('Something here')
,但是这会删除所有括号,而不管是否存在前导回显,或者也会删除回显语句。
答案 0 :(得分:1)
在记事本++中测试
查找内容:echo\s*\((.*?)\);
替换为:echo \1;
echo
,然后匹配0个或更多空格\s*
,然后匹配(
,然后非贪婪地匹配并捕获其他所有(.*?)
,直到);
echo
替换空格,并用\1
替换第一个捕获组(.*?)
)
和;
之间是否有空格这不会在诸如以下的换行符中替换:
echo('some stuff...
and more here... etc...');
但是,有一个。当您为搜索模式选择正则表达式时,匹配换行符复选框。
答案 1 :(得分:1)
\becho\K\((.+?)\)
$1
<-$ 1之前有空格. matches newline
说明:
\b # word boundary
echo # literally
\K # forget all we have seen until this position
\( # opening parenthesis
(.+?) # group 1, 1 or more any character, not greedy
\) # closing parenthesis
给出:
echo('Something here'); echo('Something
here');
给定示例的结果
echo 'Something here'; echo 'Something
here';
屏幕截图: