Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
If this data is in some file, then:
from pathlib import Path
import re
filename = 'test123.txt'
content = Path(filename).read_text()
result = re.findall(r"'(#[0-9a-fA-F]+)'", content)
print (result)
(\'.*\')
reflecting characters before quotes, dot - any character, * - take the following characters indefinitely, ( ) - each found combination will be saved as a separate result.
If the string format is known - it starts with #, then 6 characters of letters and numbers, then IMHO it's easier and clearer to look for this combination
(#[a-zA-Z0-9]{6})
# first character
[a-zA-Z0- 9] character ranges - lowercase, uppercase Latin + numbers
{6} - take where exactly 6 characters
( ) - each combination found will be a separate result
For python, you can try regexps here:
https://pythex.org/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question