Context
I use QGIS expressions and want to use regular expressions to identify those strings that contain two words. It's easy to identify those features of the field text
that contain both QGIS
or PostGIS
with this expression:
regexp_match("text", ('QGIS|PostGIS'))>0
Using with the following four features, no 1. 2 and 3 return 1
, no. 4 returns 0
.
1: 'This text contains the words "QGIS" and "PostGIS" as well as others.'
2: 'This text contains the word "QGIS" as well as others.'
3: 'This text contains the word "PostGIS" as well as others.'
4: 'This text contains differents words.'
Question
I now want to identify features that contain both words - thus not QGIS
or PostGIS
, but QGIS
and PostGIS
- so only line 1 should return 1
, all others 0
. So if using Regular expressions, the logical operator OR
is |
, I'm looking for the equivalent for the operator AND
.
In this PCRE Regex Cheatsheet, there is an example for OR
: a|b -> a or b
, but there is no and
operator. How to construct an and
connection?