^ b? A b? $
So b can match at the beginning of the string 0 or 1, and A must match one or more times. Again b can match 0 or 1 times at the end of the string.
Now I want to modify this regular expression in such a way that it can match b at the beginning or end of the string, but not b at the same time.
What should I do?
p>
^(b?A+|A+b?)$
I have this situation: the regular expression is like this Of:
^ b? A b? $
So b can match at the beginning of the string 0 or 1, and A must match one or more times. Again b can match 0 or 1 times at the end of the string.
Now I want to modify this regular expression in such a way that it can match b at the beginning or end of the string, but not b at the same time.
What should I do?
You can use a beautiful “or” operator in regexp.
^(b?A+|A+b?)$