简体   繁体   中英

SQL H2 Database select digit + alphanumeric char from string

I try to select just the numbers followed by a alphanumeric character

5h 1
5h 5 8h 8 12h 10
12h 10 48h 20
5h 1 8h 1 12h 1 24h 1 48h 1 72h 1
5h 1 8h 1 12h 1 24h 1 48h 1 72h 1

For example in the second line 5h 5 8h 8 12h 10 I need to remove numbers 5, 8, 10 ie which are not followed by a character. Result should be 5h 8h 12h .

I already removed specific chars with:

REGEXP_REPLACE (resource, '[^\w\.@-]', ' ' )

Try this regex

REGEXP_REPLACE (resource, '\\b[0-9]+\\b', ' ' )

Use \\\\b if \\b doesn't work. Am not sure if it will need double escape.

Regex101 Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM