J. Bend
J. Bend

Reputation: 309

SQLite and regular expressions

I have a column in SQLite which contains strings such as:

equal_to#1 capable#4 adequate_to#1

I would like to get the following results:

equal_to, capable, adequate_to

I'm trying to get it working with replace but with no luck, perhaps someone might help me with some regex?

Upvotes: 0

Views: 322

Answers (2)

Maoritzio
Maoritzio

Reputation: 1232

Use substr and instr

select substr("equal_to#1", 0, instr("equal_to#1", '#'))

output:

equal_to

Upvotes: 2

Anton Balaniuc
Anton Balaniuc

Reputation: 11739

Your regex should be something like this:

/#\d+/g

here is an example

Upvotes: 0

Related Questions