0

For this sample string: "... Key Match extra text..."

How do I get the value "Match", which is the string between blank spaces after "Key"?

is there a better way than: Find position of "Key "->pos1, find position of first blank space after p1 -> p2, substring(string, p1,p2)?

This is not working as I expected

Select substring('Key Match extra text', 'Key (.+) ');
---
Match extra
2

1 Answer 1

1

You can make the regex be "non-greedy", so that .+ matches as few as possible:

Select substring('Key Match extra text', 'Key (.+?) ');

Or you can change . to something that won't match spaces:

Select substring('Key Match extra text', 'Key (\S+) ');
Sign up to request clarification or add additional context in comments.

1 Comment

The question mark did the trick. Thanks.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.