There is a certain string that I find using regexp, is there an opportunity to check whether there is another one in the found string
For example, I found a string using
(?i)((function|procedure) (. ?(?=stdcall)))
And I want to check if there is a result in it for
(. ?(?=((\s)|(\:))String))
For example, it should find
Function Test(aTest: String; const aPluginCall: TObject): integer; stdcall; export;
But skip
Function Test(aTest: AnsiString; const aPluginCall: TObject): integer; stdcall; export;
or
Function Test: integer; stdcall; export;
CodePudding user response:
You can use
(?si)(function|procedure)((?:(?!function|procedure|stdcall).)*[\s:]String(?:(?!function|procedure).)*)(?=stdcall)
See the regex demo.
Details:
(?si)-senables.to match line break chars andienables cas e insensitive matching(function|procedure)- Group 1:functionorprocedure((?:(?!function|procedure|stdcall).)*[\s:]String(?:(?!function|procedure).)*)- Group 2:(?:(?!function|procedure|stdcall).)*- a char other than line break chars, zero or more but as many as possible occurrences, that does not start afunction,procedureorstdcallchar sequences[\s:]- a whitespace or:String- aStringstring(?:(?!function|procedure).)*- a char other than line break chars, zero or more but as many as possible occurrences, that does not start afunctionorprocedurechar sequences
(?=stdcall)- a positive lookahead that requiresstdcalltext to appear immediately to the right of the current location.
