VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Secure Shell (https://forums.vandyke.com/forumdisplay.php?f=15)
-   -   Highlight Keyword with Regex Positive Look Ahead (https://forums.vandyke.com/showthread.php?t=14533)

WesR 05-19-2021 10:54 AM

Highlight Keyword with Regex Positive Look Ahead
 
I'm trying to highlight the sequence "site=name&" without including the "&" in the highlight.

In regex, I can use the following query and it works, but in SecureCRT highlighting it does not.
site=.*?(?=\&))
Does SecureCRT support this?

If I use "site=.*?\&", the whole sequence is highlighted including the "&".

I'm using SecureCRT Version 8.2.0 (x64 build 1402)

bgagnon 05-19-2021 12:25 PM

Hi WesR,

I think you have one too many closing parens.

This works for me in v9.0.1:
site=.*?(?=\&)

This does not:
site=.*?(?=\&))

If you think the double close parens is correct, please post the text you are testing against.

As a note, v8.2 was not even an official release but it's very old. You might check your upgrade eligibility.

WesR 05-19-2021 12:52 PM

Thanks and sorry, not sure how that extra Paren made it in there, but it is in the post only.

It still does not work for me in 8.2.

WesR 05-19-2021 01:59 PM

Here is an example of the type of string I'm testing against:

enterprise=enterprise1&site=TestSite1&area=Area1&line=Line1&

In this case,

Quote:

site=.*?(?=\&)
doesn't highlight anything.

I can see what I can do with upgrading, but because this was a corporate purchase done for me, I don't know what it might take.

Wes

bgagnon 05-19-2021 02:13 PM

Hi Wes,

Keyword highlighting/regex has been enhanced since v8.2. The first version in which this will work is v8.7.

Changes in SecureCRT 8.7 (Beta 1) -- November 20, 2019
------------------------------------------------------
New features:

  • Keyword highlighting supports the ability to match phrases and substrings and works with literal strings and regular expressions.

What did you find when you checked upgrade eligibility? What is the most recent version your license provides access to? (Please do not post the serial number here, if unsure, please send email to support@vandyke.com and we can check for you.)

WesR 05-19-2021 02:18 PM

I was able to upgrade to 8.3.4 (x64 build 1699), but unfortunately get the same results.

Wes

WesR 05-19-2021 02:20 PM

Just saw your post. I don't think I can get to 8.7 or higher easily.

Thanks

WesR 06-03-2021 04:01 PM

1 Attachment(s)
hmmm well I was able to purchase a license for 9.0.2 :), but I get the same results.

Quote:

site=.*?(?=\&)
does not work.

Using the following does, but includes the &.

Quote:

site=.*?\&
As can be seen in the attachment.
https://forums.vandyke.com/attachmen...achmentid=2116
The string I am testing against is:
enterprise=enterprise1&site=TestSite1&area=Area1&line=Line1&
Thanks

bgagnon 06-03-2021 04:28 PM

1 Attachment(s)
Hi Wes,

And, as before, it does highlight the correct characters for me. :)
https://forums.vandyke.com/attachmen...achmentid=2118
That is the text you expect to be highlighted, correct?

Are you sure the version is 9.0?

Please embed a graphic showing the same category in your Session Options configuration.

If that might expose sensitive info, send an email to support@vandyke.com and reference Attn Brenda - Forum Thread #14533 in the subject line (and attach the screenshot).

bgagnon 06-03-2021 04:33 PM

Hi WesR,

By the way, a colleague just informed me a look-ahead is not even necessary for what you are trying to accomplish.

If you use this pattern, you should also get the desired results:

Code:

  site=[^\&]+

WesR 06-03-2021 06:04 PM

3 Attachment(s)
Ha! Thanks. That workaround without lookaround does work!

I am still curious why the other query is not working. Attached are a some screenshots. I didn't escape the & in the first one. It seems to work either way including with your workaround.

I was just about to click send when I thought... Hey, my List has a lot of things being highlighted. I created a new list with just the
Quote:

site=.*?(?=\&)
Regex in it and it works!

I also checked in my old 8.3 version and the workaround works with that version as well.

WesR 06-03-2021 06:57 PM

Ok, so I copied my LogErrors.ini file to a new file and restarted.

I then started deleting things. First all the Regex entries and then the other entries. I am left with only the one Regex entry and it still doesn't work. I now have a test file with one entry that works and the LogErrorsCopy with one entry that doesn't. Both only 'show' the one entry.

Test:
Quote:

D:"Match Case"=00000000
D:"Regex Line Mode"=00000001
Z:"Keyword List V2"=00000001
"site=.*?(?=\&)",0080ff80,00000001
LogErrorsCopy:
Quote:

S:"Keyword List"=denied eofexception err error Exception fail failure forbidden warn
D:"Match Case"=00000000
D:"Regex Line Mode"=00000000
Z:"Keyword List V2"=00000001
"site=.*?(?=\&)",0020ff42,00000001
What is this Keyword list and why doesn't it appear in the GUI?

Removing the Keyword List line and reloading SecureCRT showed no change.
Changing the Regex Line Mode to 1 did allow it to work.

This seems to equate to the Advanced/Match style setting which is new. Setting this to Phrases and substrings allowed this to work with all the highlighting rules I have tried. Yeah!

Wes

bgagnon 06-04-2021 08:17 AM

Hi WesR,
Quote:

Hey, my List has a lot of things being highlighted. I created a new list with just the ...
So it was likely a case of "precedence" (order). There was a match based on a regex higher in the list before it reached the one you really wanted it to match on. :)

I am glad you have resolved the issue.

WesR 06-04-2021 08:47 AM

This was not a case of Precedence or Order.

I attempted to convey that I changed it until there was a single entry and it still failed.

It was due to the new (to me and my old version) Keyword Highlighting/Advanced setting set to Whole words. Once I set this to Phrases and Substrings, it worked with my whole list as well as the single list.

Do you know what the
Quote:

S:"Keyword List"=denied eofexception err error Exception fail failure forbidden warn
is and why it is not displayed in the GUI?

Is this just an old item that is no longer supported or something?

bgagnon 06-04-2021 09:04 AM

Hi WesR,

My apologies if I missed something. You have posted a lot of info in a short period of time. :)

I do not know why that string is in the Keyword List name field. Manually editing keyword list INI files is very much discouraged as the format may change from version to version. Are you sure the correct format was retained in the file after your edits?


All times are GMT -6. The time now is 04:50 PM.