\b :
\b allows you to perform a “whole words only” search using a regular expression in the form of \bword\b. A “word character” is a character that can be used to form words. All characters that are not “word characters” are “non-word characters”.
Example :
sampleStr = ‘find it and replace what you find.’
regexp : /\bfind\b/g;
result: it will match at index 0 and 29
whereas
if sampleStr = ‘find it and replace what youfind.’
result: it will match at index 0 only
The m (multiline) flag
If the m (multiline) flag is not set, the ^ matches the beginning of the string and the $ matches the end of the string. If the m flag is set, these characters match the beginning of a line and end of a line, respectively. Consider the following string, which includes a newline character:
var str:String = “Catch me if you can\n”;
str += “catch but do not catch me if you can not”;
trace(str.match(/^\w*/g)); // Match a word at the beginning of the string.
Even though the g (global) flag is set in the regular expression, the match() method matches only one substring, since there is only one match for the ^–the beginning of the string. The output is:
Here is the same code with the m flag set:
var str:String = “Catch me if you can\n”;
str += “catch but do not catch me if you can not”;
trace(str.match(/^\w*/gm)); // Match a word at the beginning of lines.
This time, the output includes the words at the beginning of both lines:
at index 0 and 21