- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How does \B regular expression work in Python?
The word boundary \b matches positions where one side is a word character (usually a letter, digit or underscore)
\B matches all positions where \b doesn't match.
The following code shows how regexpr \B works
import re result = re.findall(r'\Bcat', 'certificate') result2 = re.findall(r'\Bcat', 'tomcat') result3 = re.findall(r'\Bcat', 'catfish') print result, result2,result3
This gives the output
['cat'] ['cat'] 
- How does [\d+] regular expression work in Python?
- How does BackReference work with Python Regular Expression with Unicode?
- How regular expression modifiers work in Python?
- How regular expression alternatives work in Python?
- How regular expression anchors work in Python?
- Regular Expression \b Metacharacter in Java
- Regular Expression a|b Metacharacter in Java
- What does “?:” mean in a Python regular expression?
- Construct a Finite Automata for the regular expression ((a+b)(a+b))*.
- How to write a regular expression to match either a or b in Python?
- Regular Expression Examples in Python
- Regular Expression Modifiers in Python
- Regular Expression Patterns in Python
- Regular Expression Matching in Python
- How regular expression grouping works in Python?