w3schools
  
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About

JavaScript RegExp \b Metacharacter


RegExp Object Reference JavaScript RegExp Object

Definition and Usage

The \b metacharacter is used to find a match at the beginning or end of a word.

If no match is found, it returns null.

Syntax

new RegExp("\bregexp")

or simply:

/\bregexp/


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The \b metacharacter is supported in all major browsers.


Example

Example

Do a global search for "W3" at the beginning or end of a word in a string:

var str="Visit W3Schools";
var patt1=/\bW3/g;

The marked text below shows where the expression gets a match:

Visit W3Schools

Try it yourself »


RegExp Object Reference JavaScript RegExp Object

DreamTemplate

WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
Top Web Hosting
Cheap UK Web Hosting
WEB BUILDING
XML Editor – Free Trial!
FREE Flash Website
FREE Web Templates
SEO Company
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
STATISTICS
Browser Statistics
Browser OS
Browser Display
FLIGHT TICKETS
Find the cheapest flight
to any destination now!
SHARE THIS PAGE