从Notepad ++中的PL / SQL文件中提取所有对象名称

时间:2019-03-22 16:06:02

标签: sql regex notepad++

我需要从Notepad ++中的PL / SQL程序包主体文件(* .spb)中获取函数,过程,游标名称和其他目标,例如从以下sql脚本中获取:

create or replace PACKAGE BODY pac_emp3 AS
PROCEDURE p_buscar_salario_emp3 (p_employee_id IN employees.employee_id%TYPE,
                                 p_employee_name OUT employees.first_name%type,
                                 p_string IN OUT varchar2)
AS
v_salario employees.salary%TYPE;
BEGIN
SELECT salary, first_name INTO v_salario, p_employee_name FROM employees WHERE employees.employee_id = p_employee_id;
p_string := 'Procedimiento terminado';
DBMS_OUTPUT.PUT_LINE('Salario: '|| v_salario);


END p_buscar_salario_emp3;

FUNCTION f_foo RETURN NUMBER IS
   SELECT 1+1 FROM DUAL;
   RETURN 1;
END;

END pac_emp3;

在这种情况下,我只需要提取: 程序p_buscar_salario_emp3

或仅使用对象和对象名称查找文本:

PROCEDURE p_buscar_salario_emp3
FUNCTION f_foo

与FUNCTION名称等相同

我知道使用正则表达式是可能的,但是只有一个正则表达式呢?

2 个答案:

答案 0 :(得分:0)

此正则表达式应为您工作。

((PROCEDURE|FUNCTION) \S+) 

如果您需要添加更多术语,请像这样键入它们:

((PROCEDURE|FUNCTION|NEW_TERM) \S+) 

答案 1 :(得分:0)

  • Ctrl + H
  • 查找内容:>> captureWarpPoints('man11.jpg'); Error using images.internal.imageDisplayParsePVPairs (line 71) The parameter, notruesize, is not recognized by imageDisplayParsePVPairs Error in images.internal.imageDisplayParseInputs (line 69) [common_args,specific_args] = images.internal.imageDisplayParsePVPairs(varargin{:}); Error in imshow (line 245) images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:}); Error in captureWarpPoints>updateRef (line 133) refImgHandle = imshow(modRefImage, 'notruesize'); Error in captureWarpPoints (line 29) updateRef(1, refImage, refPoints)
  • 替换为:(?:\A|\G)(?:(?!(?:PROCEDURE|FUNCTION)).)*((?:PROCEDURE|FUNCTION)\s+\w+)(?:(?!(?:PROCEDURE|FUNCTION)).)*$1\n
  • 检查环绕
  • 检查正则表达式
  • 检查$1\r\n
  • 全部替换

说明:

. matches newline

替换:

(?:\|\G)                    # non capture group, beginning of strig or restart from last match position
(?:                         # start non capture group
  (?!                       # start negative lookahead
    (?:PROCEDURE|FUNCTION)  # non capture group PROCEDURE or FUNCTION (you can add other keywords)
  )                         # end lookahead
  .                         # any character
)*                          # end group, may appear 0 or more times
(                           # start group 1
  (?:PROCEDURE|FUNCTION)    # non capture group PROCEDURE or FUNCTION (you can add other keywords)
  \s+                       # 1 or more spaces
  \w+                       # 1 or more word character
)                           # end group 1
(?:                         # start non capture group
  (?!                       # start negative lookahead
    (?:PROCEDURE|FUNCTION)  # non capture group PROCEDURE or FUNCTION (you can add other keywords)
  )                         # end lookahead
  .                         # any character
)*                          # end group, may appear 0 or more times

给定示例的结果

$1          # content of group 1
\n          # linefeed, use \r\n for windows line break