Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Technical

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 3rd June 2010, 09:54
mike_p mike_p is offline
Senior Member
 
Join Date: Mar 2010
Location: Surrey, England
Posts: 140
Thanks: 9
Thanked 28 Times in 17 Posts
Default Any regex experts: I need help for nano syntax highlight rules

I use the nano editor for quick edits of php files on my server.

The syntax highlighting is great apart from its ability to handle heredoc syntax for comments.

The current 'rules' for syntax highlighting comments are:
Code:
color green "//.*"
color green "#.*"
color green start="/\*" end="\*/"
Unfortunately the third rule causes any line starting '//*' to be seen as the start of a block of comment instead of a single line. This means that whole blocks of non-comment code get highlighted as comments. '//*' is often used by heredoc.

I need the regex to change the third rule to accept '/*' but not '//*' for the start of a comment block.

(I have tried various versions but my regex ability is rubbish!)

Can anyone help. (Pretty lease!)
Reply With Quote
Sponsored Links
  #2  
Old 3rd June 2010, 11:45
mike_p mike_p is offline
Senior Member
 
Join Date: Mar 2010
Location: Surrey, England
Posts: 140
Thanks: 9
Thanked 28 Times in 17 Posts
 
Default

attempts so far...

I've tried specifying no '/' before: [^/]/\*
- didn't work

I've tried specifying whitespace before: \s/\*
- that worked for spaces but not new lines
- new lines I can easily handle as a separate case
- but then needs to be expanded to allow whitespace as part of a character class so...

I've tried specifying whitespace as a class before: [\s]/\*
- didn't work !! so...

I've tried specifying whitespace as a class (with a '*' multiplier) before: [\s]*/\*
- didn't work !! so...

I've tried specifying whitespace as a class (with a '+' multiplier) before: [\s]+/\*
- didn't work !! so...

I've tried specifying characters as a class before: [a-z]/\*
- this works - but obviously I still need to allow whitespace etc

I've tried specifying characters + whitespace as a class before: [a-z\s]/\*
- works for characters, not for whitespace

so the guesses continue...
------
edited to say

I think I've established that the nanorc regex doesn't allow for \s in character classes (ie in [] ), but will accept the posix [:space:] instead. However this still doesn't inlcude LF or CR so I need to handle the start of line separately.

I have yet to work out how to do the simple version of saying NOT '/' before '/*', but have a useable implemenation of
Code:
color green start="(^/\*)|([[:alnum:][:space:].]+/\*)" end="\*/"

Last edited by mike_p; 3rd June 2010 at 12:21. Reason: update
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Spamsnake - Problem with spamassassin, FuzzyOcr and MySQL debuguser HOWTO-Related Questions 6 16th September 2008 18:37
Help Stats Webalizer jfruano Installation/Configuration 2 27th February 2007 13:03
Frustrated with ISPConfig install! woozyerdaddee Installation/Configuration 4 19th May 2006 03:38
Installation Fails... :( cyberstorm Installation/Configuration 1 15th January 2006 18:07
Install stop at uuwish, UUDeview SeaWolf Installation/Configuration 6 4th October 2005 23:53


All times are GMT +2. The time now is 23:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.