I am writing a function to find attributes value from given string and given attribute name.
The input stings look like those below:
\b, and use
Or, to match at the beginning of a string:
\W is a consuming pattern matching any non-word char (a char other than a letter/digit/
_) you won't have a match at the start of the string. A
\b word boundary will match at the start of the string and in case there is a non-word char before
If you literally need to find a match at the beginning of a string after an optional non-word char, the
\W must be replaced with
^ match the start of a string, and
\W? matches 1 or 0 non-word chars.
Also, note that
, inside a character class is matched as a literal
,. If you mean to use it to enumerate chars, you should remove it.
\b- a word boundary
^- start of string
\W? - 1 or 0 (due to the
? quantifier) non-word chars (i.e. chars other than letters/digits and
(sip[:+=]+) - Group 1:
sip substring followed with one or more
(\w+)- Group 2: one or more word chars.