Home » SQL & PL/SQL » SQL & PL/SQL » string format
string format [message #668459] Mon, 26 February 2018 06:45 Go to next message
suji6281
Messages: 134
Registered: September 2014
Senior Member
Hi Team,

How to check the format of string values.
Assume table has two rows with below values
45-896712
265-89-4578

now, i want to compare these string values are in 99-999999 or 999-99-9999 format or not.

Please help me with your suggestions.

Thank you.

Regards
sekhar
Re: string format [message #668460 is a reply to message #668459] Mon, 26 February 2018 07:15 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
suji6281 wrote on Mon, 26 February 2018 04:45
Hi Team,

How to check the format of string values.
Assume table has two rows with below values
45-896712
265-89-4578

now, i want to compare these string values are in 99-999999 or 999-99-9999 format or not.

Please help me with your suggestions.

Thank you.

Regards
sekhar
Remove the "-" characters, then do the compare
Re: string format [message #668461 is a reply to message #668459] Mon, 26 February 2018 07:54 Go to previous messageGo to next message
Solomon Yakobson
Messages: 3270
Registered: January 2010
Location: Connecticut, USA
Senior Member
WHERE TRANSLATE(string,'012345678','999999999') IN ('99-999999','999-99-9999')

SY.
Re: string format [message #668465 is a reply to message #668461] Mon, 26 February 2018 10:08 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
  1  select 'yes'
  2  from dual
  3* where regexp_like('45-896712','^\d{2}-\d{6}$')
>/

'YE
---
yes


  1  select 'yes'
  2  from dual
  3* where regexp_like('265-89-4578','^\d{3}-\d{2}-\d{4}>/

'YE
---
yes

[Updated on: Mon, 26 February 2018 10:10]

Report message to a moderator

Previous Topic: Interval Clause in Date
Next Topic: Commit after deletion of every 5000 rows
Goto Forum:
  


Current Time: Tue Apr 16 13:21:35 CDT 2024