- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How do you extract a field using regex?
00000887 ThreadMonitor W WSVR0606W: Thread "WebContainer : 24" (00000887) was previously reported to be hung but has completed. It was active for approximately 1386249 milliseconds. There is/are 0 thread(s) in total in the server that still may be hung.
Here, I want to extract 1386249 and thread count using a regex expression.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Try (?<milliseconds>\d+)\s+milliseconds\D+(?<thread_count>\d+)
.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

The above regex should work , but this should take care of the singular / plural aspect of the number of threads - Please remove spaces before msec and threads in the regular expression below.
"approximately\s+(?< msec>\d+).*?[is|are]\s+(?< threads>\d+)"
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


If you enter the regex string as code by indenting four spaces or surrounding it with backticks there's no need to mangle it.
This expression won't work if it contains literally "is/are" as in the example.
If this reply helps you, Karma would be appreciated.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks for the tip about entering the string as a code.
If the string is going to be 'is/are' always you are right (this wont work).
I was guessing it would be either 'is' or 'are' based on the number of threads.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


Try this regex string.
"approximately (?<msec>\d+).*?are (?<threads>\d+)"
If this reply helps you, Karma would be appreciated.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


Converted this response to an unrelated question into a new question.
If this reply helps you, Karma would be appreciated.
