开发者

oracle regular expression - search for a particular string

开发者 https://www.devze.com 2023-04-11 21:55 出处:网络
I have a data in a column like this Test 20019-2000 test Test 119 test Test 19-EM Test EM - 19 SO, when I开发者_如何学JAVA do a REGEXP_LIKE(mesage,\'19\') it is retrieving all the 4 records. But my

I have a data in a column like this

Test 20019-2000 test
Test 119 test
Test 19-EM
Test EM - 19

SO, when I开发者_如何学JAVA do a REGEXP_LIKE(mesage,'19') it is retrieving all the 4 records. But my requirement is that , it should fetch the rows in which, the token string is starting with "19".

SO it should fetch 3 and 4th row only. Please help me on this.

Thanks in advance.


Oracle regexp does not support the traditional word boundry operators \b or \<. But you can simulate this by matching the start of string OR a non-word character immediately before the 19.

E.g. Here I define a word as being a sequence of alphanumerics. So you need

REGEXP_LIKE( mesage, '(\A|\W)19' )

Will match 19, fred 19, fred.19, but not fred19. If you do want to define a word as being non whitespace, and thus not match fred.19 change it to

REGEXP_LIKE( mesage, '(\A|\s)19' )
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号