0

I would like to extract from this string: FREQ=DAILY;BYDAY=MON,TUE,WED,THU,FRI;BYHOUR=7;BYMINUTE=0;BYSECOND=0 the number that is after 'BYHOUR=' string using Oracle pl/sql.
It can be 1 or 2 character long (0-23)
It is probably best to use regex regular expression but I was never fluent in creating them.

Can someone help and explain it?

0

1 Answer 1

2

Use REGEXP_SUBSTR:

SELECT REGEXP_SUBSTR(col, 'BYHOUR=(\d{1,2})')
FROM yourTable
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, it worked, the output though is: 'BYHOUR=12'. Is it possible to get only a number in this statement (using regex) or do I have to use substr() method to get it?
I think you could change it to this REGEXP_SUBSTR(col, '(\d{1,2})',instr(col,'BYHOUR'))
@chris See duplicate question's answer
select to_number(substr(REGEXP_SUBSTR(col, 'BYHOUR=(\d{1,2})'), 8)) from your table

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.