Pattern=re.compile (ur "[({] [^ () () {}] * [)}\])]") does not understand

pattern=re.compile(ur"[(\[{][^(){}]*[)}\]]")
all_subs=pattern.split(cell_text)

what do you mean by solving these two lines of code

Mar.17,2021

this regular expression is used to match a paragraph in parentheses, preceded by

.
[(\[{]

matches the left parenthesis, the middle paragraph

[^(){}]*

matches any number of characters that are not parentheses, with the last

[)}\]]

matches the right parenthesis. The reason why the left parenthesis and the right parenthesis are so long and regular is to be compatible with parentheses, square braces and curly braces, and even Chinese parentheses.

pattern.split uses this regular expression to separate the following cell_text into an array. I'll give you an example to show you:

clipboard.png

Menu