Regexp_like [[:space:]]
Hi,
I wonder can you help, I have XML in a CLOB (I dont want to covert to XMLType), I want to find data that matches between XML tags e.g. <List1> to </List2>, the .* doesnt work when there are line returns in the clob, while the following works,
select case when regexp_like('<List1>
</List2>' ,'<List1>[[:space:]].*</List2>')
then 'Match Found' else 'No Match Found' end as output from dual;
but this isnt great if there are manys line returns/tags in betweeen e.g. List1> to </List5>, can we do this easier?
select case when regexp_like('<List1>
<List2>
<List3>
<List4>
</List5>' ,'<List1>[[:space:]].*[[:space:]].*[[:space:]].*[[:space:]].*</List5>')
then 'Match Found' else 'No Match Found' end as output from dual;
is there a command that will find everything betwen <List1> to </List5>
thanks
Edited by: SQhell on Jun 8, 2011 8:37 AM
Edited by: SQhell on Jun 8, 2011 8:58 AM
I want to see if the following data is present in the clob, <redemptionFreqList> to <recurrencePatternLabel>Day32</recurrencePatternLabel>As BluShadow mentioned: It is so much easier to (temporarily) convert to xmltype and profit from Oracle's XML functions:
You just need a well-formed xml at least:
SQL> with t as (select '
<recordKeepDesc>cash</recordKeepDesc>
<redemptionFreqList>
<CyclicCalendarVO>
<cyclicCalendarId>799</cyclicCalendarId>
<startDate class="sql-timestamp">2001-06-01 00:00:00.0</startDate>
<recurrenceType>34</recurrenceType>
<isDeleted>0</isDeleted>
<frequencyOption>0</frequencyOption>
<firstOptionDay>31</firstOptionDay>
<firstOptionMonth>76</firstOptionMonth>
<recurrenceTypeLabel>Monthly</recurrenceTypeLabel>
<recurrencePatternLabel>Day32</recurrencePatternLabel>
<startDateLabel>21-Jun-2001</startDateLabel>
<assetFrequencyId>1108</assetFrequencyId>
<astFreqId>118</astFreqId>
<trancTypeCde>redemption</trancTypeCde>
</CyclicCalendarVO>
</redemptionFreqList>
<subAccountedIndicator>033.0</subAccountedIndicator>' str from dual
select case
when existsnode (xmltype ('<x>' || str || '</x>'), 'x/redemptionFreqList/*/recurrencePatternLabel') = 1 then 'Match Found'
else 'No Match Found'
end
x
from t
X
Match Found
1 row selected.
Similar Messages
-
Use REGEXP_INSTR to find a text string with space(s) in it
I am trying to use REGEXP_INSTR to find a text string with space(s) in it.
(This is in a Function.)
Let's say ParmIn_Look_For has a value of 'black dog'. I want to see if
ParmIn_Search_This_String has 'black dog' anywhere in it. But it gives an error
Syntax error on command line.
If ParmIn_Look_For is just 'black' or 'dog' it works fine.
Is there some way to put single quotes/double quotes around ParmIn_Look_For so this will
look for 'black dog' ??
Also: If I want to use the option of ignoring white space, is the last parm
'ix' 'i,x' or what ?
SELECT
REGEXP_INSTR(ParmIn_Search_This_String,
'('||ParmIn_Look_For||')+', 1, 1, 0, 'i')
INTO Position_Found_In_String
FROM DUAL;
Thanks, WayneMaybe something like this ?
test@ORA10G>
test@ORA10G> with t as (
2 select 1 as num, 'this sentence has a black dog in it' as str from dual union all
3 select 2, 'this sentence does not' from dual union all
4 select 3, 'yet another dog that is black' from dual union all
5 select 4, 'yet another black dog' from dual union all
6 select 5, 'black dogs everywhere...' from dual union all
7 select 6, 'black dog running after me...' from dual union all
8 select 7, 'i saw a black dog' from dual)
9 --
10 select num, str
11 from t
12 where regexp_like(str,'black dog');
NUM STR
1 this sentence has a black dog in it
4 yet another black dog
5 black dogs everywhere...
6 black dog running after me...
7 i saw a black dog
5 rows selected.
test@ORA10G>
test@ORA10G>pratz
Also, 'x' ignores whitespace characters. Link to doc:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/conditions007.htm#i1048942
Message was edited by:
pratz -
Hi all,
I'm new to Oracle i needed to know incase in a column for names which can be null how do i know how many entries are there with only spaces inserted into the table...If you want to find rows where some column contains only spaces, how about:
WHERE somecolumn IS NOT NULL
AND RTRIM(somecolumn) IS NULLor from 10g onwards,
WHERE REGEXP_LIKE(somecolumn, '^ *$') -
Search for White space within strings
create table emp_dtl
(empname varchar2(23));
Insert into emp_dtl values ('WAYNE');
Insert into emp_dtl values ('JOSEPH KRUPP'); --------- has white space
Insert into emp_dtl values ('YING ZONG LEE'); --------- has white space
Insert into emp_dtl values ('COHEN');
Insert into emp_dtl values ('MARIE');How can i search for empnames which has White space in it? From other OTN threads, I gathered that this has something to do with
chr(32)But i don't know how to put this in LIKE operator.Hi,
SELECT *
FROM emp_dtl
WHERE REGEXP_LIKE (empname, '\s')
;will look for any kind of whitespace (including spaces, which are CHR (32)).
It may be more efficient to specifically list all the different whitespace characters, and see if the string changes when you remove all of them:
SELECT *
FROM emp_dtl
WHERE empname != TRANSLATE ( empname
, 'x ' || CHR (9) -- CHR (9) = <tab>
|| CHR (10) -- CHR (10) = <newline>
|| CHR (13) -- CHR (13) = <return>
, 'x'
;Edited by: Frank Kulash on Jul 12, 2010 8:47 AM -
REGEXP_LIKE not returning expected results
My first attempt at REGEXP_LIKE and I'm obviously missing something. I've tried several suggestions I found in the forum but cannot get the correct results. I need the following query to return only those rows containing only alphabetic characters (no numbers). What I get are rows containing letters and numbers.
Any help will be greatly appreciated!
Randy
SELECT order_number
FROM order_table
where REGEXP_LIKE(order_number,'[a-z A-Z]')check below the various options which you can use to search different elements
Character Class Syntax Meaning
[:alnum:] All alphanumeric characters
[:alpha:] All alphabetic characters
[:blank:] All blank space characters
[:cntrl:] All control characters (nonprinting)
[:digit:] All numeric digits
[:graph:] All [:punct:], [:upper:], [:lower:], and [:digit:] characters
[:lower:] All lowercase alphabetic characters
[:print:] All printable characters
[:punct:] All punctuation characters
[:space:] All space characters (nonprinting)
[:upper:] All uppercase alphabetic characters
[:xdigit:] All valid hexadecimal characters -
Hi we use file shares on a windows 2003 server for our storage for our macs. some of macs are 10.4 and some 10.5. We have a major problem in that when some of our windows users try and access these files they cant and even in some cases the files/folders disappear.
After a lot of rooting around we found that the macs were creating these trailing spaces/leading spaces when they either accessed or created a folder on the windows share, please someone out there tell me there is something i can do to fix this and stop this from happening.
cheersHi,
Purvesh K wrote:
One another way using Regular Expressions!!!
Assumes Alphabets or Numbers follow before and after the Space. If Special characters are to be included, query will have to be modified.This also assumes that the same column has to have both leading and training spaces. (Etbin's solution found rows where any column had either, not necessarily both, leading ad trailing spaces.)
with data (col) as
select 'first' from dual union all
select 'first ' from dual union all
select ' first ' from dual
select *
from data
where regexp_like(col, '[[:space:]]+[[:alnum:]]+[[:space:]]+')
COL
first Try adding
select 'This has embedded spaces.' from dual union allto the sample data. The code above finds this row, even though it has neither leading nor trailing spaces.
Remember that regular expressions are not anchored . The pattern can start and/or end anywhere in the string. In the example above, the substring ' has ' matches the pattern you gave. If you're using regular expressions, anchor them to the beginning and end of the string using ^ and $.
So
where regexp_like(col, '^[[:space:]].*[[:space:]]$')would be better. However, that would miss cols tha consisted of a single space. To include them:
where regexp_like(col, '^[[:space:]](.*[[:space:]])?$')OP: If none of these solutons match your needs, then we don't understand your needs. Post a little sample data (CREATE TABLE and INSERT statements, or a WITH clause, like Purvesh used) and the results you want from that data.
Regular expressions do wonderful things, but they don't do them very fast. If perfrmance is important, use TRIM (like Etbin suggested), or LIKE, or SUBSTR. -
Help with REGEXP_LIKE statement
Hello Experts
I am having little problem in solving the problem with REGEXP_LIKE as shown below.
All the records are giving me the desired result except the last one where it has alph and numeric and spaces in between.
Can I please have the solution please. I tried with INSTR but it didn't work too.
Thanks in advance
Rajesh
WITH T AS
(SELECT '000 444$888' STUDENT_ID FROM DUAL UNION ALL
SELECT '^^^^^^^^^^ ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'ABCDEFGH&' STUDENT_ID FROM DUAL UNION ALL
SELECT '!@@@@@@@ ' STUDENT_ID FROM DUAL UNION ALL
SELECT '123456*891 ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'AAA 77BBBBB ' STUDENT_ID FROM DUAL
SELECT student_id FROM T
WHERE not REGEXP_LIKE(trim(STUDENT_ID), '^[[:alnum:]]*$')Rb2000rb65 wrote:
Thanks Sven. But as you mentioned it did not solve my problem.My first two variants didn't work? Maybe you should start again and explaining which lines you want to see, which not and why.
So far you only mentioned, that the last line gives you trouble. Whatever that means.
/* this is your output */
WITH T AS
(SELECT '000 444$888' STUDENT_ID FROM DUAL UNION ALL
SELECT '^^^^^^^^^^ ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'ABCDEFGH&' STUDENT_ID FROM DUAL UNION ALL
SELECT '!@@@@@@@ ' STUDENT_ID FROM DUAL UNION ALL
SELECT '123456*891 ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'AAA 77BBBBB ' STUDENT_ID FROM DUAL
SELECT student_id FROM T
WHERE not REGEXP_LIKE(trim(STUDENT_ID), '^[[:alnum:]]*$')
000 444$888
^^^^^^^^^^
ABCDEFGH&
123456*891
AAA 77BBBBB
/* this is my output */
WITH T AS
(SELECT '000 444$888' STUDENT_ID FROM DUAL UNION ALL
SELECT '^^^^^^^^^^ ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'ABCDEFGH&' STUDENT_ID FROM DUAL UNION ALL
SELECT '!@@@@@@@ ' STUDENT_ID FROM DUAL UNION ALL
SELECT '123456*891 ' STUDENT_ID FROM DUAL UNION ALL
SELECT 'AAA 77BBBBB ' STUDENT_ID FROM DUAL
SELECT student_id FROM T
WHERE REGEXP_LIKE(STUDENT_ID, '[^[:alnum:] ]')
000 444$888
^^^^^^^^^^
ABCDEFGH&
123456*891 As you can see the last line is missing now. I thought that is what you wanted?
Edited by: Sven W. on Oct 12, 2012 6:42 PM -
SQL (Like /REGEXP_LIKE)
Can you help me to write a query which returns emp_name with the first name matches with the value in reference table?
EmployeeTable_*
Id Emp_Name
1 Mark Anthony
2 Issac Newton
3 Albert Einstein
4 Abraham Lincoln
ReferenceTable_*
First_Name
Mark
Albert
Output*
Id Emp_Name
1 Mark Anthony
3 Albert Einstein
Can we use REGEXP_LIKE here?if yes, please tell me how the query should be.
Thanks
BenYou can just join the tables with LIKE:
with emp as
select 1 as id, 'MARK Anthony' as emp_name from dual union all
select 2, 'Issac Newton' from dual union all
select 3, 'Albert Einstein' from dual union all
select 4, 'Abraham Lincoln' from dual union all
select 5, 'Markus Aurelius Cesar' from dual
), ref as
select 'Mark' as first_name from dual union all
select 'Albert' from dual
select
emp.id,
emp.emp_name
from ref
join emp
on emp.emp_name like ref.first_name||'%';But the above will give you Markus Aurelius and not MARK Anthony.
So you could do it with REGEXP_LIKE:
with emp as
select 1 as id, 'MARK Anthony' as emp_name from dual union all
select 2, 'Issac Newton' from dual union all
select 3, 'Albert Einstein' from dual union all
select 4, 'Abraham Lincoln' from dual union all
select 5, 'Markus Aurelius Cesar' from dual
), ref as
select 'Mark' as first_name from dual union all
select 'Albert' from dual
select
emp.id,
emp.emp_name
from ref
join emp
on regexp_like(emp.emp_name,'^'||ref.first_name||'([[:space:]]|$)','i')That regexp matches where emp_name begins with first_name followed by either some whitespace or the end of string. The 'i' makes the match case insensitive. -
Query help using regexp_like
kindly help me on this
DECLARE
STRING1 VARCHAR2(1000) :='NOT ( VIP5';
BEGIN
if regexp_like(string1 ,'NOT \(* VIP5') then
dbms_output.put_line('string1 is correct');
dbms_output.PUT_LINE(STRING1);
end if;
END;problem is STRING1 can be
'NOT ( VIP5 '
OR can be NOT ( VIP5'ie between NOT AND VIP5 brackets will be there with spaces or without spaces
so help me for the output
S
Edited by: oraclehema on Mar 1, 2011 3:38 AMHAI
it is working
using
declare
STRING1 VARCHAR2(1000) :='NOT ( VIP5';
STRING2 VARCHAR2(1000) :='NOT ( ( ( VIP5';
begin
if REGEXP_LIKE( string2, 'NOT[[:space:]]*\([[:space:]]*\([[:space:]]*\([[:space:]]*VIP5') then
dbms_output.put_line('string2 is correct');
dbms_output.PUT_LINE(STRING2);
end if;
end;Edited by: oraclehema on Mar 1, 2011 3:52 AM -
Bit more detail...
Mac Book Air has been struggling for space for a while so I bough at time capsule a) for back up and b) to host my itunes folder remotely. This didnt' work. I took it into the Genius bar and the genius there told me that time capsule is not designed for anything other than back up. Instead I have to connect a G drive through the time capsule's wireless router to my MBA.
I followed his instructions - moved my files from the Time Capsule and MBA directly onto the G Drive - which took a heartening 2 hrs so something must have been happening - and the held down 'Alt' when starting iTunes and selected the new itunes folder as the location of my itunes libarary which I wanted iTunes to 'point at'. When I opened iTunes only 10 albums are visible now.
In ITunes advanced preferences it says it is pointing at the correct folder. The files are all cleary there when I open the G Drive folder to take a look. But I cannot get iTunes to find them.
Any suggestions?
Secondary challenge - in spite of deleting the original itunes folder on my MBA I still get messages pop up telling me my start up disk is out of space and I need to clear some - I expected to stop getting this message now I had done this exercise above. I have emptied Trash. Again - any pointers appreciated. I am new to this world of 'intuitive' macbooks.
CheersAfter admittedly only a quick read the one thing you don't say is how you are trying to make this move. Most people with moving library issues do it the wrong way. Plenty of web sites tell you how to do it the wrong way.
If the iTunes application is started before the drive with the library is fully mounted and awake iTunes will revert back to the internal drive. -
Hi All,
I like to know, is it NULL and Space value is same in ABAP, if it is not how to check null value.
Thank you.
Senthileverything is correct though some answers are not correct.
A Database NULL value represents a field that has never been stored to database - this saving space, potentially.
Usually all SAP tables are stored with all fields, empty fields are stored with their initial value.
But: If a new table append is created and the newly-added fields do not have the 'initial value' marked in table definition, Oracle will just set NULL values for them.
as mentioned: There is no NULL value to be stored in an ABAP field. The IS NULL comparison is valid only for WHERE clause in SELECT statement. WHERE field = space is different from WHERE field IS NULL. That's why you should check for both specially for appended table fields.
If a record is selected (fulfilling another WHERE condition) into an internal table or work area, NULL values are convertted to their initial values anyway.
Hope that sheds some light on the subject!
regards,
Clemens -
Hello Gurus:
I have had to use BOTH 'null' and 'space' (ofcourse I tried 'initial' too...) when selecting data from PRPS table, otherwise all the required records were not fetched. I had to do this on two different occassions. The first is a SAP provided field and the other is customer's enhancement. I have cut-paste the two code blocks. Any ideas why?
Thanks in advance,
Sard.
***********(1)**************
select posid objnr func_area zzfunct from prps into
corresponding fields of table it_wbs
where func_area is null or
func_area eq space.
************(2)**************
select prps-pspnr prps-posid prps-post1
into (wa_test1-pspnr, wa_test1-posid, wa_test1-post1,
from prps
where prps-posid in s_wbs and
... and
( prps-zzmlind is null or prps-zzmlind eq space ).
append wa_test1 to it_test1.
clear wa_test1.
endselect.Hello Richard,
the Requirement to check for NULL corresponds to the definition of the database (field) within the DDIC. Check the flag initialize (it has also some documentation).
This flag is intended to be used if the definition of the db table is changed at SAP while the table already is used at customer side.
After deploying the corresponding patch or upgrade such a changed definition may result into the need to convert all entries. For tables with many entries this would result into inacceptable downtime. So such changes are done without the initialiazation/conversion of existing entries.
The tradeoff is the syntax you noticed.
Kind regards
Klaus -
My itouch wont let me download apps says no more space but i have no videos or photos
my itouch wont let me download apps says not enough disk space even after i have deleted old apps and have no photos or videos on it please help
- How much free/available storage space do you have? Go to Setting>General>About..
- The IPod need between two and three time the file download size to download and anstall an app.
- Connect the iPod to your computer and click on the iPod under Devices in iTunes. What is the discribution of storage usage as shown i the colored bargraph? If the "othjer" category is > i GB then try restoring the iPod to reduce the "other" -
We recently had the hard drive replaced on our Mac as part of Apple's replacement programme. Prior to sending it off for repair we did a final Time Machine back up, which was completed successfully. SInce getting the computer back we restored everything from the backup disk using Time Machine, which all worked fine, however now we are having problems with it completing regular backups. We receive a message each time telling up that the backup disk doesn't have enough space on it. It is telling us that it needs in the region of 370gb and only has around 30gb available. The computer hard drive is in the region of 350gb and the hard drive is a 400gb one. It is almost as if it is not recognising that the data already on the disk is the back up of this computer and is trying to complete a completely separate back up as opposed to just updating the backup already on the disk.
Has anyone else got any experience of this and therefore could give me some hints on what to do. I am reluctant to wipe the backup drive and start again, however I would prefer not to have to buy another hard drive if I can avoid it as this one is technically big enough
I look forward to getting some responsesHi, I never use TM myself.
Have you looked through Pondini's extensive TM help site?
http://Pondini.org/TM/FAQ.html
http://pondini.org/TM/Troubleshooting.html
Can't imaging something not being covered there.
PS. It's generally recommended a TM drive be at least twice the size of your main drive. -
Questions on SPACE on the output list...
Hi,
A report program...
If i defined a data like this:
DATA: Helloworld(26) TYPE c.
Helloworld = space.
Then when i output this variable, i will get this field filled with space for 26 characters length??? Or just a space in 1 characters length???
What else if i want to output this variable filled with space of 26 characters length...what statements could achieve this??
Thanks.Hi,
SPACE mean only one space
check this code :
DATA : Helloworld(26).
Helloworld = space.
concatenate 'test' 'test' into helloworld separated by space.
write : helloworld.
Reward points, if helpful,
Sandeep Kaushik
Maybe you are looking for
-
Is it possible to get music back off my iPhone?
I had someone work on my computer and he deleted all the music from it. Is there any way I can get my music off of my iPhone 3G? Also I have about 20gb of music on my ipod classic, can I get the music back to my computer?
-
IPhone photos not showing in places on iPad
If I take photo on iPhone it shows ok in my iPad photostream but does not appear in places. Shows ok in places on iPhone. If I take photo on iPad it shows ok in places on iPad but not iPhone. This was working ok, noticed it stopped about a week ago.
-
Problems with Print Report Queries and € sign
Hi, In one of my database fields I've prices with currency (euro sign, dollar, etc.) saved as varchar2. In PDF report I need to make some calculations with this value, so I thought of dividing it into 2 parts, value and currency. As SQL statement I'v
-
Help: commandLink does not work.
commandLink does not work. It just simple refreshes the page, and not enter the Listener,( he listener work pretty well in other page). Is it dataTable problem? If I not use dataTable but just use JSTL & JSF commandLink and it works fine. -----------
-
IPod Touch, version 4.2.1--Overdrive Media Console
I want to listen to audiobooks from my local library on my iPod. I have downloaded Overdrive Media Console to my iMac (iTunes). The icons show that a particular book will play on an iPod (but not an iMac???). It says my version of the Console does