Regex for label=username and then isolate it

Viewed 37

This may be so simple, but im a initiate and i don't find a answer to this.

So this is my test string, i need to convert the username to a label.

I think with this code below i already converted the username as a label.

{filename="/folder/folder/folder/folder/folder/folder/File.lgw"} |= `]:The referenced account is currently locked out and may not be logged on to.`| regexp "(?P<username>)"| line_format "{{.username}}"

I am using this Test string on regex101 trying to isolate the username correctly.

[Listener 00_TEST_ACCOUNT_LOCK, address 00_TEST-ACCOUNT-LOCK_USER:username]:The referenced account is currently locked out and may not be logged on to.

I only need keep the beggining part of the code that is:

[Listener 00_TEST_ACCOUNT_LOCK, address 00_TEST-ACCOUNT-LOCK_USER: 

I can add anything to the start and end of the username to better identify it, it can be changed later on to match the server example: --username--

I already tried something so simple as a regular expression of: .*-- but im stuck there i i don't know what else i can try or if its even good

1 Answers

Because Oracle does not support look at heads you can't do what you want using regexp_substr.

However, rather than matching what you want, you can match what you * don't* want and replace it with blank, leaning you with what you want:

regexp_replace(my_column, ':username.*', ':') 
Related