I’m hoping a regex expression can extract a string beginning with “ERROR” up to but not including the text “STA”. The idea is to only show users the text string for the error message WITHOUT internal programming details (e.g. code line numbers and procedure names, etc.).
For example, the error string the application returns is always of the form:
...STA-20010: ERROR my app error message is here STA-06512: at ...
and I want to extract the following from this string:
ERROR my app error message is here
Is there a way to do this using regular expressions? If it matters, I’ll be implementing this in actionscript3.
The following should do what you want:
The
.*?will match as few characters as possible such that the lookahead(?=STA)succeeds.It might be necessary to add word boundaries as well depending on your error messages, for example:
That way on a string like the following you would include
STACKOVERFLOWas a part of the error message instead of stopping because it starts withSTA: