I explain the 3 UltraEdit regular expression you used here and what are the problems.
1) %[ ^t]+^([a-z^-]+^) ^{division^} ^{section^}% ... start the search at beginning of a line.
[ ^t]+ ... find
1 or more spaces/tabs at beginning of a line. So the line with word
division or
section must have preceding whitespaces. If that is not true, you should append a second
+ to change the meaning to
0 or more spaces/tabs at beginning of a line.
^([a-z^-]+^) ... matches a string consisting only of letters A-Z, a-z and the hyphen character and this part of the found string is tagged and therefore only this part of the found string is displayed in the function list view.
The next character must be a single space.
Then either the word
division or the word
section must follow in any case. The space character inside
^}^{ should be remove because there should no space between the 2 arguments of the OR expression.
This expression will therefore not find any of the lines in your example.
2) %[ ^t]++^([0-9a-z-_]++[~end-if .]^).^% ... again start the search at beginning of a line.
[ ^t]++ ... find
0 or more spaces/tabs at beginning of a line, in other words preceding whitespaces are allowed and should be ignored.
[0-9a-z-_]++ ... should find a string consisting of only letters, numbers and the hyphen character. Well, the hyphen character has normally no special meaning, except in square brackets where it means FROM x TO y. Usually the hyphen is used for something like 0-9 or a-z in a square bracket, but it is also possible to use it for example for character range
!-/ which means all characters in ASCII (or ANSI or Unicode) table from the exclamation mark to the slash character. Therefore inside a square bracket the hyphen character should be always escaped with
^ when simple the hyphen character itself is meant. In this regular expression string the hyphen character is surely read as hyphen character because the letter z belongs already to a character range definition. But nevertheless the hyphen character should be escaped here with a preceding
^. Also interesting is that
++ is used instead of just
+.
++ means this part of the found string can be also an empty string with no characters. I'm quite sure that this is not correct.
[~end-if .] ... is in combination with the previous expression the reason why the two lines you marked are not found. This expression means that the next character after 0 or more letters, digits or hyphens should NOT be either the character e or E, the character n or N, one of the characters D to I in any case, the character f or F, a space or a point. [~...] does not mean NOT the string in the square bracket, the expression means not any character listed inside the square bracket with character ranges also possible. The result with the previous expression is a definition of overlapping character classes which is never good because the result is weird for beginners although full explainable for experts in regular expressions.
The next character must be a point and the final escape character
^ is completely useless here.
3) % 0000-^mainWell, this regular expression simply finds lines starting with " 0000-main". The escape character
^ is simply useless here because the next character m has no special regular expression meaning and the hyphen left is not inside a square bracket and therefore needs also no escape character to be interpreted as hyphen character.
I don't know anything about syntax of Cobol, but I suggest following:
/Function String = "%[ ^t]++^([a-z^-]+^) +^{division^}^{section^}
/Function String 1 = "%[ ^t]++^([0-9]+-[a-z][a-z^-]++^)."
The second expression means in words:
- Find a string at beginnig of a line,
- with optionally preceding whitespaces,
- with a number with at least 1 digit,
- and a hyphen character after the number,
- and next character is a letter,
- and zero or more additional letters or hyphens,
- and a point.
Maybe this expression excludes already strings which should be found and maybe finds strings which should be ignored. If you can tell us in words the syntax rules for function strings for Cobol, and post an example code best enclosed within BBCode
[code]...[/code] tags containing strings which should be found and strings which should not be found, and post in a second block what you want to see in the function list view for this example code block, we can find a better regular expression.
A lookbehind to exclude
end-if. is not possible with the UltraEdit regular expression engine. But there are possibly other methods to exclude them or we change to the Perl regular expression engine which supports lookbehinds to evaluate a found string already within the search for ignoring it. An extreme example of such a lookbehind usage in Perl regular expression function strings can be viewed at topic
How to define a case sensitive function string search?