6,826625
Grand MasterGrand Master
6,826625

PostJul 08, 2025#16

There can be used in the wordfile:

Code: Select all

/TGBegin "Squared strings"
/TGFindStr = "(\[(?!(?:MY)?DEFINE).+?])"
/TGEnd
The expression in the marking group searches anywhere in file for an opening square bracket where next is neither MYDEFINE nor DEFINE because of the negative lookahead defined with (?!) and one more more characters except newline characters non-greedy and a closing square bracket.

Note: UltraEdit expects just one function definition within a line. There is displayed in the function list only [#FUNCT_M=25] for the line:

Code: Select all

#bloc = YES,[#FUNCT_M=25][$;ACHSEN ZURUECKSETZEN];
The Perl regular search expression matches also next [$;ACHSEN ZURUECKSETZEN] but UltraEdit does not run one more search with the defined regular expression on a line for which an expression like above found already a string to display in the function list.

There can be used the following extended expression to get both square bracket strings listed on one line in the Function List view.

Code: Select all

/TGBegin "Squared strings"
/TGFindStr = "((?:\[(?!(?:MY)?DEFINE).+?])+)"
/TGEnd
There is added in comparison to above a non-capturing group around the expression to find a string in square brackets with neither MYDEFINE nor DEFINE after [ with the multiplier + for not stopping the search already on first positive match but continue the search for even more such strings in square brackets. I post the expression here once more with colors to easier see which round brackets are a pair and which multiplier (formatted bold) belongs to which round bracket pair:

((?:\[(?!(?:MY)?DEFINE).+?])+)
  1. () is a capturing group which defines what to display in the function list which is here the entire found string.
  2. (?:)+ is a non-capturing group to find one or more strings matched by the expression inside which means multiple strings in square brackets with neither MYDEFINE nor DEFINE after the opening square bracket.
  3. (?!) is a negative lookahead to check if there is after the opening square bracket not a string as defined by the expression inside.
  4. (?:)? is an inner non-capturing group with the multiplier for zero or one times.

17
Basic UserBasic User
17

PostJul 09, 2025#17

Thanks Mofi again, you did much more, than I needed 😉
I only need lines starting with the bracket (I just put the "^" in the code) and do not need additional searches in a line, but good to see, how it could work. If I follow your explanations, I can understand a little bit, what happens, but I it is unbelievable for me, how someone can create such expressions. Anyhow, perhaps I can cook better than you 😂 (but do not think so.)

Thanks

PostJul 28, 2025#18

Hello,

again I have a little question.
I have following code:

Code: Select all

/TGBegin "Unterprogramme"
/TGFindStr = "^%_N_(.*)$"
/TGBegin "Operationen"
/TGFindStr = "^.*?MSG(.*)$"
/TGFindBStart = "%_N_"
/TGFindBEnd = "(?:%_N_|\z)"
/TGEnd
/TGEnd
/Regexp Type = Perl
How to change the second line in code to find a text like "%_N_3668_MPF", which already works OR a line like "; %_N_3668_MPF".

Thanks a lot!

6,826625
Grand MasterGrand Master
6,826625

PostJul 28, 2025#19

There can be used:

Code: Select all

/TGFindStr = "^[ ;]*%_N_(.*)$"
That expression additionally accepts also zero or more normal spaces or semicolons in any order at the beginning of a line before the string %_N_.

There could also be used:

Code: Select all

/TGFindStr = "^(?:; *)?%_N_(.*)$"
That expression additionally accepts also optionally a semicolon at the beginning of a line followed by zero or more normal spaces before the string %_N_.

17
Basic UserBasic User
17

PostJul 28, 2025#20

Perfect, thank you!

PostNov 30, 2025#21

Hello again :-). I tried to "translate this into the Perl expression, but it does not work quite well.

Code: Select all

/TGFindStr = "%[0-9]+?^(LBL?[1-9][0-9]++^)"

my solution:

/TGFindStr = "^[0-9]+[\t ]+LBL[\t ]+([1-9]+)"
Goal would be listing all LBL... which are not LBL 0

2025-11-30_17h19_22.png (81.7KiB)

What is missing in my code?

Thanks, Dirk

6,826625
Grand MasterGrand Master
6,826625

PostNov 30, 2025#22

There must be used in the syntax highlighting wordfile:

Code: Select all

/TGFindStr = "^[0-9]+[\t ]+(LBL[\t ]+[1-9][0-9]*)"
This Perl compatible search expression searches from the beginning of a line for one or more digits followed by one or more horizontal tabs or normal spaces followed in a capturing group by the string LBL followed by one or more horizontal tabs or normal spaces followed by a single digit not being 0 and zero or more digits.

17
Basic UserBasic User
17

PostDec 02, 2025#23

Wonderful, thank you :-)

PostDec 04, 2025#24

And another question, I tried but I cannot finish. I search for this text. 
2025-12-04_09h15_55.png (22.28KiB)

My tries:
2025-12-04_09h13_08.png (9.6KiB)

First one shows the whole line instead of stopping on MACHINING_PPCOMM=
Second shows only first letter.
So I guess, I will need help again here :-)

And perhaps it is possible, also to show the value of MACHINING_NUMBER in the function list? Example: 2 Zentrieren (anpassen)

Thank you

6,826625
Grand MasterGrand Master
6,826625

PostDec 04, 2025#25

There could be used for finding the string after MACHINING_COMM=:

Code: Select all

/TGFindStr = "MACHINING_COMM=((?:(?![\t ]+MACHINING).)+)"
There is inside the capturing group (most outer round brackets) a non-capturing group with (?:) on which the multiplier + is applied to match one or more characters for which the expression inside is positive.

The expression inside the non-capturing group begins with a negative lookahead to check if from current position in character stream there are not one or more horizontal tabs followed by the string MACHINING. If that condition is true, the character at current position in the character stream is matched by the dot which matches all characters except newline characters (by UltraEdit default).

The lookahead condition is true for the characters of the string Zentrieren 1 (anpassen) and false with next space/tab. The matching stops for that reason on closing round bracket for this example. It stops also at the end of a line because of the dot does not match a carriage return or a line feed.

Please note that not all versions of UltraEdit have embedded a version of the Perl compatible regular expression engine supporting a lookahead with a variable number of characters caused by [\t ]+ in the negative lookahead expression. It would be necessary to use a different lookahead expression if your used version of UltraEdit does not work with that expression tested with UE v2025.1.0.20 on several example lines with different amount of spaces/tabs left to MACHINING__PPCOM.

There could be used also:

Code: Select all

/TGFindStr = "MACHINING__NUMBER=([0-9]+)[\t ]+MACHINING_COMM=((?:(?![\t ]+MACHINING).)+)"
That matches also the number before with a capturing group and the function list displays 2 Zentrieren 1 (anpassen).

17
Basic UserBasic User
17

PostDec 04, 2025#26

Great,both works fine with V24.20 :-) Again thank you very much for your time!

PostDec 05, 2025#27

Code: Select all

^(.*?\(.*)$
gives me every line with brackets and text in between. But how can I get only the lines, which start with a bracket? Thanks :-)
2025-12-05_10h16_38.png (26.17KiB)

6,826625
Grand MasterGrand Master
6,826625

PostDec 05, 2025#28

Use ^[\t ]*(\(.+\)) to find lines with zero or more horizontal tabs or normal spaces at the beginning of a line which are ignored for the function list display as not inside the capturing group.

The first character not being a horizontal tab or normal space in a line must be an opening round bracket. This character is already in the capturing group.

Next must be found one or more characters except newline characters. This expression is greedy which means it does not stop matching characters on first closing round bracket in a line, but on last closing round bracket in a line.

The line must have at least one closing round bracket which is the last character matched by the expression inside the capturing group for the display in the function list view. The rest of the line like trailing tabs/spaces or more text are ignored by the search.

There could be used also ^[\t ]*\((.+)\) with the capturing group excluding first opening and last closing round bracket to get in the function list view displayed only the string between the first opening and the last closing round bracket.

The use of .+? instead of .+ in the search expression changes the matching behavior for the characters between an opening and a closing round bracket to non-greedy which means the matching behavior stops on first closing round bracket in the line instead of the last closing round bracket.

Read more posts (-2 remaining)