Topic: SQL*Plus and PL/SQL >> Regular Expression Problem
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: Regular Expression Problem |
| Lyad |
Posted: Feb 01, 2007 05:11:45 AM |
Total Post: 12
Joined: Jan, 2007
|
Can anyone tell me How should I use regular expression to check a string containing only alphabet and number.
The thing I need is :
I allow 'aA3 d', 'Aa4 ', '5 A_bc', '5 A B- C' i.e. all possibble combination with apace,alphabet(both cases),and number and '-' or '_'.
except -,_,and space not as first character
But I don't allow !,%,*,(,.,/,},{,(,",+,=,<,>, at any position.
Could anybody help me regarding this.
|
|
|
Lyad |
| Posted: Feb 01, 2007 12:23:39 PM | |
|
Total Post: 12
Joined: Jan, 2007
|
One thing I forgot to mention is I need to allow \' apostrophe also.
Thanks.
|
|
|
|
|
ankur |
| Posted: Feb 02, 2007 02:29:36 AM | |
|
Total Post: 59
Joined: Nov, 2006
|
use the escape character ............
Specify Escape in the query and the character as '\' or '_'
whatever u want to allow
|
|
|
|
|
ebrian |
| Posted: Feb 03, 2007 12:12:04 AM | |
|
Total Post: 1
Joined: Feb, 2007
|
This should work for you:
[code]SQL> select * from foo;
A1
--------------------
aA3 d
Aa4
5 A_bc
5 A B- C
-ABC
12'YZ
A!B
7 rows selected.
SQL> select * from foo
2 where regexp_like(a1, '^[[:alnum:]](\w|[''_ ])+', 'i');
A1
--------------------
aA3 d
Aa4
5 A_bc
5 A B- C
12'YZ[/code]
|
|
|
|
|
Lyad |
| Posted: Feb 05, 2007 04:33:51 AM | |
|
Total Post: 12
Joined: Jan, 2007
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 856 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 281 |
| neeraj sharma | 254 |
| Ramesh Jois | 245 |
| Bishal Khetan | 207 |
|
|