0

when i am trying extract through regexp from the below source by using \|(.*?),1,2 this, i am getting up to end but i need to 3rd / only. when i use \|(.*/){1,3},1,2 it is giving http://localhost:6148372/content/bdsajf and i am stuck up at ending search position. please help me on this.

U=https://www.abcdf.com/aecb/app/login|http://llcwokhfkdvc.webs.com/sajc-services
U=http://localhost:7438/en.html|http://localhost:6148372/content/bdsajf/en/kjf-LKJf/FJKSF-cbxjs.html

O/P should be # http://llcwokhfkdvc.webs.com and http://localhost:6148372

Thanks

3 Answers 3

1

Try the following expression:

\|([^/]*/*[^/]*)

See live demo

Sign up to request clarification or add additional context in comments.

2 Comments

your logic is working but i am in a confusion how this picks http as well, can you explain how it behaves ?
[^/]* matches everything up to the first / in // and then /* matches the two forward slashes, and [^/]* match everything up to the following /
0

Try '\|([^/]*/){1,3}' (11i):

SQL> SELECT regexp_substr(txt, '\|(([^/]*/){1,3})', 1, 1, 'i', '1') regexp
  2    FROM DATA;

REGEXP
--------------------------------------------------------------------------------
http://llcwokhfkdvc.webs.com/
http://localhost:6148372/

In 10g:

SQL> SELECT ltrim(regexp_substr(txt, '\|([^/]*/){1,3}'), '|') regexp
  2    FROM DATA;

REGEXP
--------------------------------------------------------------------------------
http://llcwokhfkdvc.webs.com/
http://localhost:6148372/

2 Comments

I think the author didn't want the slash (/) sign at the end of the results.
Neither can I, but he wrote what he wants to get: http://llcwokhfkdvc.webs.com and http://localhost:6148372 Just saying, cheers.
0

You can try:

SELECT regexp_substr(t, '\|(http://.*?)/', 1, 1, NULL, 1)
  FROM (
    SELECT
      'U=https://www.abcdf.com/aecb/app/login|http://llcwokhfkdvc.webs.com/sajc-services' AS t
    FROM DUAL
    UNION
    SELECT
      'U=http://localhost:7438/en.html|http://localhost:6148372/content/bdsajf/en/kjf-LKJf/FJKSF-cbxjs.htmlO/P should be # http://llcwokhfkdvc.webs.com and http://localhost:6148372' AS t
    FROM DUAL
);

Comments

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.