Forum Discussion
ELW
Advocate II
7 years agoRemove strings within parentheses from Power Query Editor
Is there a way to remove various strings from within parentheses from the query editor in PowerBI? There could be 0, 1, or multiple instances of text within parenthesis I need to remove from my stri...
- 7 years ago
ELW ,
An simple way than power query is to write a python script to replace (...) using non-greedy matching.
# 'dataset' holds the input data for this script import pandas as pd dataset["AFTER"] = dataset.replace(to_replace=r'\(.*?\)', value='', regex=True)
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ELW
Advocate II
7 years agoThanks parry2k! I believe that just replaces the parentheses themselves while leaving the text inside them. Is there a way to modify that formula to remove the text from inside the parentheses as well?
v-yuta-msft
Community Support
7 years agoELW ,
An simple way than power query is to write a python script to replace (...) using non-greedy matching.
# 'dataset' holds the input data for this script import pandas as pd dataset["AFTER"] = dataset.replace(to_replace=r'\(.*?\)', value='', regex=True)
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.