I want to create a regex that match ‘.’, ‘#’ and ‘:’ and also match everything inside these brackets ‘[‘ & ‘]’ such as [foo] & [bar]
I already have this match string.match(/[.#:]/g) for ‘.’,’#’ and ‘:’.
I know that the brackets regex should look like this \[.\]
but how do I combine them both to one condition?
thanks,
Alon
to combine them use
?: is optional and is used to not capture the group (anything in parenthesis)
UPDATE:
.+?(one or more) or.*?(for zero or more)- use this for lazy matching, otherwise [ sdfsdf][sdfsddf ] will be matched