A regular expression to match all words that start with a specific character (e.g. #, @, etc) in a string.
Note that don’t forget to replace the P in the regex with your own character.
/(?<!\w)P\w+/g
Matches:
- Prefix
- Pattern
- Putty
Non-matches:
- prefix
- patternP
- 12345
See Also:
- Regex To Match A line That Doesn’t Contain A Specific Word
- Regex To Match A String That Doesn’t End With Given Suffix
- Regex To Match A String That Doesn’t Start With Given Prefix
- Regex To Check If A String Starts And Ends With An Alphabetic Character