Problem: Given any sentence, break it into separate words. (The words are separated by spaces).
Solution: select doc.EXTRACT('/l/text()').getstringVal() from (select 'I am a bad man' given from dual ) T , TABLE(xmlSequence(EXTRACT(XMLTYPE(''REPLACE(T.given,' ','')''),'/doc/l'))) doc
('I am a bad man' is an example)
1 comment:
Anonymous
said...
This can also be achieved using SELECT TRIM(',' FROM SUBSTR('I AM A BAD MAN'||' ',NVL(LAG(R.T) OVER (ORDER BY R.T),0)+1,R.T-NVL(LAG(R.T) OVER (ORDER BY R.T),0))) DONE FROM (SELECT INSTR('I AM A BAD MAN'||' ',' ',1,ROWNUM) T FROM ALL_OBJECTS)R WHERE R.T<>0
I am an ordinary person with some simple abilities to learn, think,
classify,create,define and decode.
I am specifically good at storing,retreiving and modifying data. I have a stranger's lonely glance in my eyes and a child's endless queries in my heart.
negative regexp
-
if you want to grep anything except foo, use grep -v or negative lookahead
echo -e 'foo\nbar\nboz'|grep -P '^(?!.*foo).*$' bar boz it is just so
beautiful ...
Upcoming Events...
-
I took some time off from the road at the beginning of 2014 - getting ready
to get back on the road again, lots of trips scheduled from February till
the e...
Add Code w/ Syntax Highlighting to PowerPoint
-
…or any media that supports rich text or HTML. I often include
code-snippets or queries in technical presentations. I find them much more
visually appealin...
The Two Ways of Doing a Job
-
Whether it's deployment, development, performance tuning, troubleshooting
or something else, there are two fundamentally different ways of doing your
job: ...
1 comment:
This can also be achieved using
SELECT TRIM(',' FROM SUBSTR('I AM A BAD MAN'||' ',NVL(LAG(R.T) OVER (ORDER BY R.T),0)+1,R.T-NVL(LAG(R.T) OVER (ORDER BY R.T),0))) DONE
FROM
(SELECT INSTR('I AM A BAD MAN'||' ',' ',1,ROWNUM) T FROM ALL_OBJECTS)R
WHERE R.T<>0
Kartik
Post a Comment