Reputation: 4497
I have this regular expresion
/\[found:([a-zA-Z0-9-_: |=\.]+)]/
that checks if my string contains things like this for example:
[found:user id=1|class=admin]
However there are some cases where my pattern may look like this:
[found:user id=1|class=admin /]
so basicly it has an optional ' /' at the end. How can I put this in my regex?
Upvotes: 2
Views: 33
Reputation: 85883
This should do the trick:
/\[found:([a-zA-Z0-9-_: |=\.]+)(\s*\/)?]/
If the space isn't optional then use \s
instead of \s*
or \s+
for at least one space.
Upvotes: 2