pl sql . pattern matching problem


 
Thread Tools Search this Thread
Top Forums Programming pl sql . pattern matching problem
# 1  
Old 10-11-2011
pl sql . pattern matching problem

hi everyone
i am facing a strange problem
Code:
declare
 v_var number(10);
 begin
if( regexp_like('RCDORMS_MMS_*_DAR','RCDORMS_MMS_*_DAR'))
then
v_var:=20;


dbms_output.put_line(v_var);
end if;
end;
/


please tell me what's the wrong thing in this expression..
as i am not able to get any output
# 2  
Old 10-11-2011
Quote:
Originally Posted by aishsimplesweet
...
i am facing a strange problem
Code:
declare
 v_var number(10);
 begin
if( regexp_like('RCDORMS_MMS_*_DAR','RCDORMS_MMS_*_DAR'))
then
v_var:=20;
dbms_output.put_line(v_var);
end if;
end;
/


please tell me what's the wrong thing in this expression..
as i am not able to get any output
Nothing strange about it really.
You don't see any output because your regular expression "RCDORMS_MMS_*_DAR" does not match your literal string "RCDORMS_MMS_*_DAR".
What you are saying by your regular expression is this:

Code:
/RCDORMS_MMS_*_DAR/
 
Match any string that has
 
(1)  "R" : the character "R", followed by
(2)  "C" : the character "C", followed by
(3)  "D" : the character "D", followed by
(4)  "O" : the character "O", followed by
(5)  "R" : the character "R", followed by
(6)  "M" : the character "M", followed by
(7)  "S" : the character "S", followed by
(8)  "_" : the character "_", followed by
(9)  "M" : the character "M", followed by
(10) "M" : the character "M", followed by
(11) "S" : the character "S", followed by
(12) "_*" : zero or more occurrences of the character "_", followed by
(13) "_" : the character "_", followed by
(14) "D" : the character "D", followed by
(15) "A" : the character "A", followed by
(16) "R" :the character "R", followed by

Now, if you look at your literal string, you'll see that the match fails at step # 13.

The step # 12 succeeded, because you have ONE occurrence of the character "_" which makes the phrase "zero or more occurrences" TRUE.

But it (i.e. the character "_") is **NOT** followed by an underscore as required by the regex.

It is followed by a literal asterisk character ("*").

Hence the regex fails to match your string and you see no output.

Note that the asterisk ("*") is a "metacharacter" in POSIX BRE, i.e. it has a special meaning in a regex; you cannot use its literal meaning. Also note that Oracle follows POSIX specification for regular expressions.

HTH,
tyler_durden

Last edited by durden_tyler; 10-11-2011 at 06:11 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pattern matching problem

if i have to do pattern match for file name with digit alphanumeric value like this File_1234.csv File_12sd45rg.csv i am using this File_*.csv and File_*.csv for digit pattern match. when i am doing pattern match for the digit then both alphanumeric match and digit match is coming. ... (3 Replies)
Discussion started by: ramsavi
3 Replies

2. Shell Programming and Scripting

Pattern matching problem

Hi I need a bash script that can search through a text file for all lines starting with 71502FSC1206 on every line it finds starting with this I need to place a letter F at the 127 position on that line. Thanks Paul (6 Replies)
Discussion started by: firefox2k2
6 Replies

3. Shell Programming and Scripting

Pattern matching and format problem

Hi I need a bash script that can search through a text file and when it finds 'FSS1206' I need to put a Letter F 100 spaces after the second instance of FSS1206 The format is the same throughout the file I need to repeat this on every time it finds the second 'FSS1206' in the file I have... (3 Replies)
Discussion started by: firefox2k2
3 Replies

4. Shell Programming and Scripting

pattern matching problem

# cat email.txt | grep -i "To:" To: <test@example.com> # cat email.txt | grep -i "Subject" Subject: Test Subject: How are you. I need to print only test@example.com from To field need to eliminate "< & >" from To field and need to print entire subject after Subject: It should be #... (7 Replies)
Discussion started by: mirfan
7 Replies

5. Shell Programming and Scripting

problem using sed for pattern matching

if abc.sh is 192.168.1.41 then the output that i get is v5c01 my code is sed 's/192.168.1.4/v5c0/g s/192.168.1.41/acc1/g' abc.sh 2>&1 | tee abc.sh i want to find 192.168.1.4 and replace it with v5c0 and find 192.168.1.41 and replace it with acc1 and i want to do it using sed (5 Replies)
Discussion started by: lassimanji
5 Replies

6. Shell Programming and Scripting

Pattern matching problem in PERL script

Hi Friends, As my old friends knows, I'm old to shell script but very new to perl script, currently I'm writing a PERL script with the following functionality: I've multiple product directories, like BUSS, FIN, SALES, MKT etc., : /export/home/GLK/BUSS, /export/home/GLK/FIN, ... (11 Replies)
Discussion started by: ganapati
11 Replies

7. Shell Programming and Scripting

Pattern Matching problem in UNIX

Hello All, I need help I have a problem in searching the pattern in a file let us say the file contains the below lines line 1 USING *'/FILE/FOLDER/RETURN') ................. ................. line 4 USING *'/FILE/FOLDER/6kdat1') line 5 USING... (2 Replies)
Discussion started by: maxmave
2 Replies

8. Shell Programming and Scripting

pattern matching problem

FilesToBackup='*.track* *.xml *.vm* *.gz Trace* TRACE* "*core*" *.out fcif_data_* esi_error_* *.rollback *.sed R.* APStatus_* log* *.output* send_mail* downenv* check_env* intaspurge_db_* sqlnet.log *.rpt *.html *.csv "*TSC*"' and i am using it like this- echo Moving files from $(pwd): ... (2 Replies)
Discussion started by: namishtiwari
2 Replies

9. Shell Programming and Scripting

problem with CASE pattern matching

I am using ksh on a HP Ux. I have a simple script but am having problem with the case statement:- #!/usr/bin/sh Chl=”SM.APPLE_SWIFT_DV” LoConfirm=”” case $chl in ) LoConfirm=”Using channel at Building 1” echo “test conditon1” echo $LoConfirm;; ) LoConfirm=”Using... (2 Replies)
Discussion started by: gummysweets
2 Replies

10. Shell Programming and Scripting

pattern matching problem

I have a file with the following contents; NEW 85174 MP081 /29OCT07 CNL 85986 MP098 /28OCT07 NEW 86014 MP098 /28OCT07 NEW 86051 MP097 /27OCT07 CNL 86084 MP097 /27OCT07 Now I have to retrieve all lines that start with NEW and where the next line starts with CNL and where the MP codes are... (8 Replies)
Discussion started by: rein
8 Replies
Login or Register to Ask a Question