highlighting words greater than 30 characters long

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
hdm
Posts: 1
Joined: Fri Jul 10, 2009 7:21 pm

highlighting words greater than 30 characters long

Post by hdm »

I have to edit big files to conform to Oracle standards with plsql syntax highlighting. Can I modify the plsql.syn file to hightlight all words in these files that contain more that 30 charaters in length? Oracle does not allow object names to be greater than 30 charaters.

TIA
HD
User avatar
Bob Hansen
Posts: 1517
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

Sorry, the answer is NO.

The syntax files have no wild card or RegEx capabilities. You can only select complete specific "words" or strings between spaces.
Hope this was helpful.............good luck,
Bob
User avatar
trids
Posts: 69
Joined: Wed May 07, 2003 10:16 am
Location: South Africa

some workarounds

Post by trids »

There are some workarounds you could try though ..

The quickest one is to use this regular expression in the Find dialog to highlight words of more than 30 chars in length:

Code: Select all

\<[^ \t=]{31,}\>
.. This will take you to each exception individually within the context of the document.

Taking this a step further, you can get a quick summary if you then use the [Mark All] button, and then step through the hits with the [Next Bookmark] command or hotkey (i have mine mapped to F2)

And one more step further, you can copy out the bookmarked lines for separate inspection (Edit > Copy Other > Bookmarked lines ).

You can even modify this approach with external RegExp commandline utilities such as sed and grep, in order to give you a hot-link index into the document where targets are found. More details on request 8)

One last workaround to consider, depending on your needs. If you really want to, you can actually HIGHLIGHT exceptions to the 30-char rule in a format for presentation (ie where you use the syntax file's colouring feature to achieve the highlight effect). The way to do this is to cunningly abuse these parameters in the syn file:

Code: Select all

CommentStart = #.
CommentEnd = .#
or

Code: Select all

CommentStartAlt = ~
CommentEndAlt = ~
or

Code: Select all

CharStart = [
CharEnd = ]
.. The idea is to choose characters that are not normally part of your Oracle standards, insert these characters into your document where the 30-char rule is broken. Assuming you choose the CommentStartAlt and CommentEndAlt characters (~) above, you would apply the following RegExp replacement:
Find what..

Code: Select all

\<[^ \t=]{31,}\>
Replace All with..

Code: Select all

~&~
Effectivley this will wrap each exception in a pair of tildes (~), identifying the text to the syn file as Comments2-type text.

Then, choose colour highlights for your document class to display/print Comments2 text in a suitably gaudy hue. Like bright green on red :twisted:

Hope this helps!
Post Reply