How can I use regex for all words beginning with : punctuation?
This gets all words beginning with a:
\ba\w*\b
The minute I change the letter a to :, the whole thing fails. Am I supposed to escape the colon, and if so, how?
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.
\bmatches between a non-alphanumeric and an alphanumeric character, so if you place it before:, it only matches if there is a letter/digit right before the colon.So you either need to drop the
\bhere or specify what exactly constitutes a boundary in this situation, for example:That would ensure that there is no letter/digit/underscore right before the
:. Of course this presumes a regex flavor that supports lookbehind assertions.