How to find everything which goes after symols #TR= and it is inside [ ] using re module. For example #TR=[ dfgg dfgddfg dgfgf dgdgdg dfgfg ]
How to find everything which goes after symols #TR= and it is inside [
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to search for just the first occurrence of this pattern, use:
If you want to find all occurrences in the text, use:
Remember to check whether the characters you are searching for have special meaning in regular expressions (like
[or]). If they are special, escape them with the backslash:\[.Also remember, that by default, regular expressions are “greedy” which means they try to get as much text to match the pattern as possible; so if you use
.*(which means “match any character except newline”; details) instead of[^\]]*(which means “match until the]is found, and stop before it”), too much text could be matched:You can also use the “non-greedy” modifier
?in your pattern, after the qualifier (*,+) which enables the “the-less-characters-the-better” matching (use*?,+?). The result could be more readable:instead of:
There’s a great online tool to test your patterns as-you-type: RegExr by Grant Skinner.