Problem
I use QGIS with the expression function regexp_matches()
that returns an array of all strings captured by capturing groups. Regular expressions normally capture only the first match (occurence) in a string. So for example the following expression:
regexp_matches('These are my QGIS strings!','(s.)')
returns only [ 'se' ]
, as expected: the first occurence of s
(position 4 of the input string), followed by the next character.
Question
How to rewrite the expression to capture all occurences of s
, followed by the next character? The result I want would look like: [ 'se', 'st', 's!' ]
What I tried
Using the regexp search pattern '(s.).*(s.).*(s.)'
would be a workaround. It's not very elegat as you already have to know how often s
occurst. There seems to be a /g
modifier in regular expressions for global matching, however, I was not able to find out the correct syntax.