Remove in side '(data)' in string python, I have string like this "i am learning python programming, (Because) it is easy langue for new learner(s)" i want to remove first (Because) data only. In side (data) may vary anything. Not constant.
Asked
Active
Viewed 52 times
-2
-
and also it is easy language for new learners(s). Thanks for your replay – Saikumar Kshatriya Jan 03 '20 at 12:01
-
Does this answer your question? [Python non-greedy regexes](https://stackoverflow.com/questions/766372/python-non-greedy-regexes) – shimo Jan 03 '20 at 12:07
1 Answers
0
You can use regex:
>>> import re
>>> string = "i am learning python programming, (Because) it is easy langue for new learner(s)"
>>> ''.join(re.split(r"\([^)]*\)", string))
'i am learning python programming, it is easy langue for new learner'
The pattern searches for opening brace, then any stuff except closing brace, then closing brace.

Vicrobot
- 3,795
- 1
- 17
- 31
-
1
-
Sorry for that, Inside brackets may vary any data not exactly (Because). – Saikumar Kshatriya Jan 03 '20 at 12:20
-
-
@Vicrobot I have one doubt sir, Can we get inside parenthesis data, It may varies anything like above. – Saikumar Kshatriya Jan 06 '20 at 13:01
-