2 Upvotes

Using Re with Python to Extract Substring

Python
General Python

import re

string = 'Clothing Brand - Nike'
search_result = re.search('Clothing Brand - (.*)')
brand = search_result.group(1)
print(brand)

***
OUTPUT
***

> Nike

By GregHe1979 - Last Updated Sept. 8, 2021, 10:16 p.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Python For Else Loop
Python
General Python

Loop

2
Top Contributors
103
100