+ 8
Find all characters, that are not in brackets
"hallo##abc[def]fg[hij]##[def]bc" I want to find hallo, abc,fg and bc but only find fg. import re field = "hallo##abc[def]fg[hij]##[def]bc" x = re.findall("[(?<=\])^][a-z\#]*[(?=\[)(?=$)]", field)
9 Respostas
+ 7
â€âąâ đđąđąđđš đđĄđđČđđ„ ââąâ€ , What do you mean exactly when you say that this is a dangerous solution?
+ 6
For all those who are not familiar with RegEx, (e.g. me đ
) here another solution:
inp = "hallo##abc[def]fg[hij]##[def]bc"
inp = inp.replace('##',',')
inp = list(inp)
while '[' in inp:
inp[inp.index('['):inp.index(']')+1] = ''
print(''.join([i for i in inp]))
It can be modified to create a single string, not words.
+ 4
Lothar
I'm also not familiar that even I didn't knew that the 're' module is called regexđ
before this thread.
+ 1
x = re.findall("(.*?)(?:\[.*?\]|$)",field)
0
â€âąâ đđąđąđđš đđĄđđČđđ„ ââąâ€ Bahhađ§
uffff please explain