Home » SQL & PL/SQL » SQL & PL/SQL » Query to get whether a string contains 2 upper characters and numbers using regular_exp (Oracle 10g)
- Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587011] Wed, 12 June 2013 07:20 Go to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Hi All ,

Will you please give me a sample query to check whether a string contains 2 upper characters and numbers are present in that character using regular_exp .

Thanks and Regars
Rakesh
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587014 is a reply to message #587011] Wed, 12 June 2013 07:26 Go to previous messageGo to next message
Littlefoot
Messages: 21825
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Test case, please? Show us some values, indicate which ones are valid. Because, your requirement is rather vague. Which 2 upper characters? Where are they located? Anywhere in the string? At the beginning of the string? Etc.
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587037 is a reply to message #587014] Wed, 12 June 2013 07:56 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

select  fg  from (select 'ad12D23456ADZd&' fg from dual);


Will you please give me a sample query to check whether a string contains 2 upper characters and numbers are present in that character using regular_exp .

If the condition pass want to return 1 else 0

Thanks

[Updated on: Wed, 12 June 2013 07:57]

Report message to a moderator

- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587039 is a reply to message #587037] Wed, 12 June 2013 07:57 Go to previous messageGo to next message
Littlefoot
Messages: 21825
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You call THAT a test case? I don't even know whether it is valid or not.
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587043 is a reply to message #587037] Wed, 12 June 2013 08:00 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

And you didn't answer the questions.
2 upper character consecutive or not? at the beginning of the string? at the end? in the middle?
And what about the numbers? Speicify!

And provide a test case with more than 1 row, with several valid rows and invalid rows.
And explain why they are valid or not.

Regards
Michel
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587049 is a reply to message #587043] Wed, 12 June 2013 08:05 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

select  fg  from (select 'ad12D23456ADZd&' fg from dual);


Will you please give me a sample query to check whether a string contains 2 upper characters and numbers are present in that character using regular_exp .
If the condition pass want to return 1 else 0

These are some of the test cases

ADad12341  - 1
ad12df331  - 0
Adweweww1  - 0
asA12fg4f  - 0
A1234D121  - 0
123erQq1A  - 1


Thanks
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587052 is a reply to message #587049] Wed, 12 June 2013 08:14 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Michel Cadot wrote on Wed, 12 June 2013 15:00

And you didn't answer the questions.
2 upper character consecutive or not? at the beginning of the string? at the end? in the middle?
And what about the numbers? Speicify!

And provide a test case with more than 1 row, with several valid rows and invalid rows.
And explain why they are valid or not.

Regards
Michel

- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587053 is a reply to message #587049] Wed, 12 June 2013 08:18 Go to previous messageGo to next message
joy_division
Messages: 4963
Registered: February 2005
Location: East Coast USA
Senior Member
rakeshramm wrote on Wed, 12 June 2013 09:05

A1234D121  - 0
123erQq1A  - 1



How many back and forths are going to occur? Why not do it correct the first time so we don't have to keep on asking you, jeez! Explain your results. You expect us to know what's in your head with these poor examples?
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587055 is a reply to message #587053] Wed, 12 June 2013 08:23 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Hi All

The entry will be done my user as his password .We want to include this check as part of password check .so we cant predict about the string the rule is that it should contain 2 upper charactes and digits

Test cases

ADad12341  - 1  
ad12df331  - 0   
Adweweww1  - 0
asA12fg4f  - 0
A1234D121  - 0
123erQq1A  - 1



Thanks and regards
- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587066 is a reply to message #587055] Wed, 12 June 2013 08:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Michel Cadot wrote on Wed, 12 June 2013 15:14
Michel Cadot wrote on Wed, 12 June 2013 15:00

And you didn't answer the questions.
2 upper character consecutive or not? at the beginning of the string? at the end? in the middle?
And what about the numbers? Speicify!

And provide a test case with more than 1 row, with several valid rows and invalid rows.
And explain why they are valid or not.

Regards
Michel


- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587082 is a reply to message #587066] Wed, 12 June 2013 09:22 Go to previous messageGo to next message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Hi

2 upper characters will not be consecutive .It will be any where in the string . Numbers also will be in scattered order .

ADad12341  - 1  
ad12df331  - 0    not valid because no upper character
Adweweww1  - 0    not valid because only one upper character
asA12fg4f  - 0    not valid because only one upper character
AaadaQwse  - 0    not valid because no digits
123erQq1A  - 1


- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587115 is a reply to message #587082] Wed, 12 June 2013 10:27 Go to previous messageGo to next message
Michel Cadot
Messages: 68761
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
SQL> With
  2    data as (
  3      select 'ADad12341' val from dual union all
  4      select 'ad12df331' val from dual union all
  5      select 'Adweweww1' val from dual union all
  6      select 'asA12fg4f' val from dual union all
  7      select 'AaadaQwse' val from dual union all
  8      select '123erQq1A' val from dual 
  9    )
 10  select val,
 11         case 
 12           when regexp_like(val, '[A-Z].*[A-Z]') and regexp_like(val, '\d.*\d')
 13             then 1
 14           else 0
 15         end res
 16  from data
 17  /
VAL              RES
--------- ----------
ADad12341          1
ad12df331          0
Adweweww1          0
asA12fg4f          0
AaadaQwse          0
123erQq1A          1

6 rows selected.

Regards
Michel

[Updated on: Wed, 12 June 2013 10:28]

Report message to a moderator

- Re: Query to get whether a string contains 2 upper characters and numbers using regular_exp [message #587117 is a reply to message #587115] Wed, 12 June 2013 10:37 Go to previous message
rakeshramm
Messages: 175
Registered: September 2006
Location: Oracle4u.com
Senior Member

Thanks All

Great Thanks Michel . Its working fine

Previous Topic: Reading mutiple files
Next Topic: ORDER BY
Goto Forum:
  


Current Time: Tue Jul 08 00:51:03 CDT 2025