I use EditPad Pro text editor. I need read string into code, but I need to ignore ones that start with the label "/*" or tab + /*, for example:
/**
* Light up the dungeon using "claravoyance"
*
* memorizes all floor grids too.
**/
/** This function returns TRUE if a "line of sight" **/
#include "cave.h"
(tab here) /* Vertical "knights" */
if (g->multiple_objects) {
/* Get the "pile" feature instead */
k_ptr = &k_info[0];
}
put_str("Text inside", hgt - 1, (wid - COL_MAP) / 2);
/* More code*** */
I like to return:
"Text inside"
I have try this (reading Regular expression for a string that does not start with a sequence), but not work for me:
^(?! \*/\t).+".*"
any help?
Edit: I used:
^(?!#| |(\t*/)|(/)).+".*"
And it return:
put_str("Text inside"
I'm close to finding the solution.
EditPad obviously supports variable-length lookbehind in pro version 6 and lite version 7 since it's flavor is indicated as "JGsoft": Just Great Software regular expression engine.
Knowing this and without the use of capture groups, you could combine two variable length lookbehinds:
(?<!^[ \t]*/?[*#][^"\n]*")(?<=^[^"\n]*")[^"]+
(?<!^[ \t]*/?[*#][^"\n]*")
The negative lookbehind for avoiding the quoted part to be preceded by [ \t]*/?[*#]
any comments, which could be preceded by any amount of space/tab. Made the /
optional, as a multi-line comment can also start with *
.(?<=^[^"\n]*")
The positive lookbehind for assuring, that there's any amount of [^"\n]
, characters, that are no quotes or newlines
followed by one quote before.[^"]+
As supposed to be always balanced quoting, now it should be convenient, to match the non-quotes
after the first double-quote
(which is inside the lookbehind)"
may occur in any line (not balanced), change the end: [^"]+
to [^"\n]+(?=")
Possibly there are different solutions for the problem. Hope it helps :)