User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Syntax highlighting, code folding, brace matching, code indenting, and function list
2 posts Page 1 of 1
Hi everybody!

I am trying to enhance SQL syntax highlighter. In particular, our model-to-sql tool generates files like the one below.

We consider '-- Table: [Chat].[tblChatRoom] ---' as a function beginning. So I want UE to extract function name from this string.

The problem is that I would like displayable function name to be in the form of 'Chat.tblChatRoom' that is with square brackets removed.

So far I was only able to extract table name with this:
Code: Select all
/TGFindStr = "-- Table: ^[[a-zA-Z_]+^]^.^[^([a-zA-Z_]+^)^]"

However without schema prefix it is of little use because of ambiguities.

Source sample:
Code: Select all
-- -----------------------------------------------------------------------------
-- Table: [Chat].[tblChatRoom] -------------------------------------------------
-- -----------------------------------------------------------------------------
CREATE TABLE [Chat].[tblChatRoom]

-- -----------------------------------------------------------------------------
-- Table: [Dbo].[tblUser] ------------------------------------------------------
-- -----------------------------------------------------------------------------
CREATE TABLE [Dbo].[tblUser]

Can anybody suggest a solution?
Thank you

PS: I'd be grateful for pointing me to the reference of UE regex dialect.
Okay, first the hints where to find information about UltraEdit regular expression syntax.

  1. By opening help of UltraEdit (for Windows),
  2. switching to tab Index,
  3. typing Find and hitting key RETURN to open help page about Find command,
  4. it can be found the line:
    UE help wrote: For information regarding creation of regular expressions see Regular Expressions or Perl Regular Expressions help.
The first link definitely missing UltraEdit/Unix as part of the link text opens on click the help page explaining completely UltraEdit and Unix regular expression syntax. The help page for Perl regular expressions is of course not complete as the Perl syntax is so complex (and powerful) that it fills entire websites and books.

But help for UltraEdit syntax can be even found directly in Find/Replace window by clicking on the regular expression builder button (.* or in older versions a magnifying glass or a triangle arrow) which opens a (complete for UE/Unix and frequently used for Perl) list of possible special characters with short explanation for the find respectively replace string. Clicking on a list item inserts the special character(s) at current position of caret in find/replace string.

There is a big problem for your requirement on display in function list. While up to 9 tagged expressions can be used on an UltraEdit regular expression replace, only the string found by the UltraEdit regular expression in first tag is displayed in the function list. Therefore the UE regular expression string:

Code: Select all
/TGFindStr = "-- Table: ^[^([A-Z_]^)+^]^(.^)^[^([A-Z_]+^)^]"

results in getting in the function list just Chat and Dbo. This limitation of UltraEdit function string search can't be worked around.

mysql.uew installed with UE v22.0.0.66 contains a line with /Regexp Type = Perl below the block with the function strings which means that all function strings are in Perl syntax.

The same function string as above in Perl syntax would be:

Code: Select all
/TGFindStr = "-- Table: \[([A-Z_]+)](\.)\[([A-Z_]+)\]"

The behavior regarding strings found by the expression in marking groups is different with using Perl regular expression engine. Instead of just first string being displayed in function list, all strings of the marking groups are concatenated to a string and the resulting string is displayed in the function list.

Unfortunately for you, although in general very useful, the concatenation of the strings is done by inserting exactly 1 space between each found string. So with above Perl expression the function list shows:

Code: Select all
Chat . tblChatRoom
Dbo . tblUser

instead of

Code: Select all

The best suggestion I can offer is to use Perl expression:

Code: Select all
/TGFindStr = "-- Table: \[([A-Z_]+)]\.\[([A-Z_]+)\]"

to get in function list:

Code: Select all
Chat tblChatRoom
Dbo tblUser

The dot is replaced now by a space in function list.

By the way: The function strings are always searched case-insensitive (except a special flag is used at beginning of a Perl regular expression string to force case-sensitive search for this string). Therefore [A-Z_]+ finds the same strings as [a-z_]+ and as [A-Za-z_]+. As it does not make a difference for the search, it is up to you what you use in the wordfile. Well, faster is always a case-sensitive search which could be achieved with using Perl engine with:

Code: Select all
/TGFindStr = "(?-i)-- Table: \[([A-Za-z_]+)]\.\[([A-Za-z_]+)\]"

(?-i) at beginning of search string turns off case-insensitive search making the search case-sensitive for this expression.
Best regards from Austria
2 posts Page 1 of 1