Tuesday, 28 August 2012

[GeSHi-devel] Doubts regarding Regular Expressions in GeSHi

Hi,
 
Thanks to Carne's response to my previous question, I was able to understand and work on REGEX for a couple of language files. Now, I am running into new problems. I want to use REGEXPS and highlight the following cases.
 
1. This is related to the mainframe language JCL [Job Control Language]. Here is a brief background. There is a concept called Symbolic variables. They are like regular variables which are substituted at runtime when the Job is submitted. For example, a typical scenario would be as follows
 
//INPUT  DD DSN=&SYSUID.SEQ.FILE,DISP=SHR
 
Here &SYSUID is the symbolic variable and will be substituted with the actual user id (say ABCD123) during execution. I want to highlight all such variables. The rules for the variable are:

- Starts with &
 
- Not more than 8 characters and must start with an alphabet
 
- Variable end denoted by one of the characters , ' ( ) & . blank space
 
My regexp array is defined as 0 => '(&)([a-zA-Z]{1,8}[0-9]{0,})(,|\(|\)|&|\s|.|\n)'
 
All I end up getting highlighted is the &. I tried using the advanced search & replace as documented at http://qbnz.com/highlighter/geshi-doc.html#language-file-regexps. The output turns out & with the amp highlighted.
 
2. A slight twist on the above example, there is another kind of variable whose rules are:
 
- Starts with either &, ? or %
 
- Must be 8 characters or less and must start with an alphabet
 
- Variable end is denoted by either one of the following , / ' ( ) * & && % + - = blank space ?
 
My regexp array is defined as 1 => '(&|\?|%)[a-zA-Z]{1,8}[0-9]{0,}(,|/|\(|\)|\*|&|%|\+|-|=|\s|\?|.|\n)'
 
This gives me an error >> Warning: preg_replace() [function.preg-replace]: Unknown modifier '|'
 
Can someone please point out what I am doing wrong here?
 
Thanks,
Ramesh

No comments:

Post a Comment