I have a string as
str='[dbo].[AGENTS]'
I want to retreive only first bracket value using regular expression how can I do that
output : dbo
I have a string as
str='[dbo].[AGENTS]'
I want to retreive only first bracket value using regular expression how can I do that
output : dbo
You could do that using groups:
test_string = '[dbo].[AGENTS]'
pattern = "\[(\w+)\].\[(\w+)\]"
match = re.match(pattern, test_string)
print(match.group(1))
dbo