我正在提取有关程序包主体文件的一些信息,现在我需要在同一文件中获取程序包引用(调用的程序包)。如何在带有正则表达式的Notepad ++中做到这一点?
通过
标记搜索,我知道使用正则表达式是可能的pac_\w*
并取消标记行,但我只需要包名称,而不需要行。
例如,如果我有此代码部分:
pac_test1.function1(...);
if pac_finally.f_result then
pac_execute.p_result;
v_load := pac_gui.f_show_result(pnum1, pnum2);
.
.
我希望得到这个:
pac_test1
pac_finally
pac_execute
pac_gui
或需要:
pac_test1, pac_finally, pac_execute, pac_gui
答案 0 :(得分:1)
Notepad ++可能不是适合此工作的工具,因为您将使用的典型方法是搜索诸如public override void WillPresentNotification(UNUserNotificationCenter
center, UNNotification notification,
Action<UNNotificationPresentationOptions> completionHandler)
{
if (notification.Request.Content.Body != null)
{
string[] notifdata = notification.Request.Content.Body.Split(',');
if (notifdata.Length > 1)
{
var content = new UNMutableNotificationContent();
content.Title = "New News Item";
content.Subtitle = notifdata[0];
//content.Body = "Body";
content.Badge = 1;
content.CategoryIdentifier = notifdata[1];
content.Sound = UNNotificationSound.Default;
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(10, false);
var requestID = "notificationRequest";
var request = UNNotificationRequest.FromIdentifier(requestID, content, trigger);
UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) =>
{
if (err != null)
{
// Report error
System.Console.WriteLine("Error: {0}", err);
}
else
{
var runcount = Preferences.Get("count", 0);
// Report Success
System.Console.WriteLine("Count is" + runcount);
System.Console.WriteLine("Notification Scheduled: {0}", request);
}
});
}
之类的东西。但是问题在于,NPP从整条生产线开始运行,并最终替换了该生产线。没有匹配项的行将需要删除,这很棘手。
因此,我建议使用PHP之类的应用程序语言。这是一个可以找到所有匹配项的PHP脚本:
答案 1 :(得分:1)
(?:^|\G).*?(pac_\w+)(?:(?!pac_).)*(\R|\z)?
$1,
. matches newline
说明:
(?:^|\G) # beginning of line OR restart from last match position
.*? # 0 or more any character but newline, not greedy
(pac_\w+) # group 1, pac_ followed by 1 or more word characters, the package
(?:(?!pac_).)* # Tempered greedy token, make sure we haven't pac_
(\R|\z)? # optional group 2, any kind of linebreak or end of file
替换:
$1, # content of group 1, package, a comma and a space
给出:
pac_test1.function1(...); pac_test2
if pac_finally.f_result then
pac_execute.p_result;
v_load := pac_gui.f_show_result(pnum1, pnum2);
给定示例的结果
pac_test1, pac_test2, pac_finally, pac_execute, pac_gui,