Regex: word boundaries -


i have search words containing capitalized letters or numbers.

i use \b[^ ]*[a-z0-9]+[^ ]*\b, instead of [^ ] use [^\b], selects phrase...

thisissometext, hass0menum8ers, likeboeing-380orrna-78.thatisgreat!

you may use \w* matching 0 or more word characters.

\w*[a-z0-9-]+\w* 

or

\s*[a-z0-9]+\s* 

and note can't include \b, \b inside character class. achieve result without including both inside character class through other ways. \s* matches 0 or more non-space characters.

demo


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -