• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 736
  • Last Modified:

Regular Expression

Can you please give me an example for the following task?

I need to extract the number after "thread" from the following string using regexp_substr in Oracle:

Archived Log entry 86041 added for thread 2 sequence 8100 ID 0xffffffff89e2d6df dest 1:

I was able to extract the first and the last number but not the one following the word thread.

I'd be glad for an example.

Thank you
0
skahlert2010
Asked:
skahlert2010
  • 3
  • 2
2 Solutions
 
skahlert2010Author Commented:
Okay, I figured out that I may use this

REGEXP_SUBSTR(mystring, '[[:digit:]]+',2,2)

Open in new window


However, there are probably numerous other attempts that are interesting to learn. So please don't hesitate if you have a suggestion!
0
 
sdstuberCommented:
if 11g, you can use subexpressions

regexp_substr(mystring,'thread ([0-9]+)',1,1,null,1)

without subexpression


substr(regexp_substr(mystring,'thread [0-9]+'),8)
0
 
sdstuberCommented:
you can use the posix class instead of range specifier in either of the solutions above
0
Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
sdstuberCommented:
another option without subexpressions

REGEXP_SUBSTR(mystring, '[0-9]+', INSTR(mystring, 'thread '))


and again,  you can use [[:digit:]] instead of [0-9] if you prefer
0
 
skahlert2010Author Commented:
Just what I needed!

Thanks again sdstuber! Nice examples!

Anything you don't have an answer for??? :-)
0
 
Geert GruwezOracle dbaCommented:
examining a logfile can be cumbersome
>> did you check table v$archived_log ?
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now