Last word in a sentence: In SQL (regular expressions possible?)

后端 未结 5 1481
夕颜
夕颜 2020-12-19 14:32

I need this to be done in Oracle SQL (10gR2). But I guess, I would rather put it plainly, any good, efficient algorithm is fine.

Given a line (or sentence, containing

5条回答
  •  感情败类
    2020-12-19 14:50

    This regex matches the last word on a line:

    \w+$
    

    And RegexBuddy gives this code for use in Oracle:

    DECLARE
            match VARCHAR2(255);
    BEGIN
            match := REGEXP_SUBSTR(subject, '[[:alnum:]]_+$', 1, 1, 'c');
    END;
    

提交回复
热议问题