[Tutor] Failing regex to identify error stack

Mats Wichmann mats at wichmann.us
Fri Sep 20 10:15:02 EDT 2019


On 9/20/19 2:09 AM, Asad wrote:
> Hi All ,
> 
> I am writing a script in python to read a logfile and identify the first
> error stack :
> 
> ?/test/admin/nothing.sql
> 
> PL/SQL procedure successfully completed.
> Session altered.
> Package created.
> Session altered.
> Session altered.
> Package body created.
> No errors.
> Session altered.
> PL/SQL procedure successfully completed.
> 
> ERROR at line 9:
> Fal-11144: size of object not allowed
> 
> 
> I am trying to use the following regex :
> 
> ^.*/test/admin/.*(?=ERROR at line .*)(?=Fal-.*)
> 
> using lookahead because seems in regex there is no && operator
> 
> Please advice .

As others have said, regexes are hard, and quite probably not the right
tool for this job.

You have not included any code, so we can't tell if you've properly set
up the search in MULTILINE mode, without that a regex has no hope of
doing the right thing when what you are looking for is, well, multiline.

If you *must* persist with a regex, debug the regex separately from the
Python code, they're really two different languages and you don't want
to have problems in one make you waste time debugging problems in the
other.  There are a number of online regex checkers you can paste into,
I like this one because it doesn't nag you with signups, etc.  There's a
button you can click to get it to believe you're using the Python flavor
of regex.

https://regex101.com/




More information about the Tutor mailing list