I am looking for a regex to find as well "right" and "all right" in a text.
I tried:
\ball\W+\w+ight\b
This only gives as a result "all right", not both "right" and "all right".
Same problem to find both it and its, it's and it is.
This should work:
\b(?:all\s)?right\b
This matches right
and an optional(?
) all
+ whitespace(\s
) in front of it, if present.
The \b
anchors are there to make sure that there is a word boundary before all
or right
and after right
.
Additionally the ?:
is here to not capture the all\s
group.
EDIT
it is / it's:
\bit(?:'s|\sis)\b
it / its
\bit(?:s)?\b