Re: Spaces
From: Álvaro G. Vicario <alvaro.NOSPAMTHANX_at_demogracia.com>
Date: Thu, 29 Jan 2009 16:57:24 +0100
Message-ID: <glsjl8$fgh$1_at_nntp.motzarella.org>
mrdjmagnet_at_aol.com escribió:
> no answer yet, but I've made some progress. Is there a way to tell
> REGEXP_INSTR to ignore spaces in my string?
>
> Sale I have this expression:
>
> SELECT REGEXP_INSTR('"FO EM, FO LA","ABCDEF","12345"','"([[:alnum:]])+,
> ([[:alnum:]]+)"') FROM DUAL;
Date: Thu, 29 Jan 2009 16:57:24 +0100
Message-ID: <glsjl8$fgh$1_at_nntp.motzarella.org>
mrdjmagnet_at_aol.com escribió:
> no answer yet, but I've made some progress. Is there a way to tell
> REGEXP_INSTR to ignore spaces in my string?
>
> Sale I have this expression:
>
> SELECT REGEXP_INSTR('"FO EM, FO LA","ABCDEF","12345"','"([[:alnum:]])+,
> ([[:alnum:]]+)"') FROM DUAL;
Do you mean something like this?
'"[[:alnum:][:space:]]+,[[:alnum:][:space:]]+"'
Or if you don't want to match stuff like '" , "':
'"[[:space:][:alnum:]]*[[:alnum:]]+[[:space:][:alnum:]]*,[[:space:][:alnum:]]*[[:alnum:]]+[[:space:][:alnum:]]*"'
This could use some polish but it's the general idea.
> I can have any number of spaces in any part of the string. How can I
> tell Oracle to ignore the spaces when performing the check? Do I need
> to replace them? I need the spaces there, but ignore them during the
> pattern match.
Well... I don't know about performance but replacing them might be the most reliable way. Writing a complex regexp that covers all cases can be tricky.
-- -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain -- Mi sitio sobre programación web: http://bits.demogracia.com -- Mi web de humor al baño María: http://www.demogracia.com --Received on Thu Jan 29 2009 - 09:57:24 CST