-2

I need to extract a string that will located between two characters, with always the same pattern

sample string:

A CRN_MOB_H_001 a--> <AVLB>

What is in bold AVLB is what I want to extract, the whole string will always have the same pattern, and everything that is before the < is irrelevant to me. The string will always have the same pattern:

Some string with possible special characters such as <>, although very unlikely so, it can be ignored if too complicated

a space

then -->

a space

and then the part that is interesting <XXXXXXX>

The XXXXXXX representing the part I want to extract

thank you for your time.

I have tried several things, could not get anywhere I wanted.

1

1 Answer 1

0

Please try this REGEXP_SUBSTR(), which selects what is in the angled brackets when they occur at the end of the string.

Note the WITH clause just sets up test data and is a good way to supply data for people to help you here.

WITH tbl(str) AS (
  SELECT 'A CRN_MOB_H_001 a--> <AVLB>' FROM dual
)
SELECT REGEXP_SUBSTR(str, '.*<(.*)>$', 1, 1, NULL, 1) DATA
FROM tbl;


DATA
----
AVLB
1 row selected.
Sign up to request clarification or add additional context in comments.

1 Comment

this works great thank you very much, it even works if the beginning of my string contains some unwanted < or >, thanks again!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.