Reputation: 5209
I'm reading the postgres docs on the like keyword, and I see:
An underscore (_) in pattern stands for (matches) any single character; a percent sign (%) matches any sequence of zero or more characters.
Is there any way to match any single or no characters?
For the purpose of the examples, I'm using the ∆
char as the operator I'm looking for:
like 'a∆b'
:
'ab' - > True
'acb' -> True
'a-b' -> True
'a.b' -> True
'a..b' -> False
'ba' -> False
...
Upvotes: 0
Views: 411
Reputation:
You need a regular expression for that:
where the_column ~ '^a.{0,1}b$'
The regex means:
a
(^
anchors at the start).
matches any character, {0,1}
is zero or one repetitions)b
($
anchors at the end)Upvotes: 3