Why does the space make all the difference?
select * from beds where id~'.*Extra large.* (Red).*';
and
select * from beds where id~'.*Extra large.*(Red).*';
The first one returned nothing and the second acted as I wanted. An example of what I want matched is:
"Extra large" (Red) {2012 model}
I thought the first would work since there is a space after (Red)?
EDIT:Even if I escape the brackets with ‘\’ I still can’t have a space there.
The problem is that you have not escaped your brackets around
"Red". Your regex should be:This makes the brackets literal brackets, but without escaping them they create a regex group (and not characters to be matched).
Your first regex grouped the characters
Redand required a space to precede that groupRed, so it would match"... Red...", but there is a bracket in your input beforeRed, so it doesn’t match.Your second regex accepts any character(s) (via
.*) beforeRed, so it matches.