Home > database >  Grab the same characters from the string
Grab the same characters from the string

Time:10-12

For similar to 111/222/333/222/333/222 string, to the inside of the 222 now fetching out, the reality is not know some of the string, 222, may be three, may be 5, is there a way to grab all of the unknown will be 222,

CodePudding user response:

In pl/SQL circulation can cough up

CodePudding user response:

A little didn't understand what meaning, fetching out refers to the column values are found out in 222? Find out is to find out that a list of values or just check a few 222?

CodePudding user response:

Using the fuzzy matching col like '% 222%' or function instr (col, '222') & gt; 0, this?

CodePudding user response:

What's grasp?

CodePudding user response:

refer to the second floor js14982 response:
a little didn't understand what meaning, fetching out refers to the column values are found out in 222? Find out is to find out that a list of values or just check a few 222?

Is that the actual application is similar to 'name: "123"; Code: "234"; Name: "345," code "456" 'this string, and then scoop out the value behind the name, I now is to use substr and instr specified, such as the value behind the first name, but how many specific string name is unknown, so I want to ask what method,

CodePudding user response:

Find out how many fixed string

(length (col) - length (the replace (col, 'name', ')))/length (' name ')

CodePudding user response:

So beat the string value, if need to intercept or judgment, in accordance with the gourd painting gourd ladle can,
With TMP as
(select "name:" 123 "; Code: "234"; Name: "345"; Code: "456" 'as p_str from dual)
The select regexp_substr (TMP) p_str, '[^;] + ', 1, level)
The from TMP
Where 1=1
Connect by level & lt;=regexp_count (TMP) p_str, '[^;] + ');

CodePudding user response:

With xx as
(select "name:" 123 "; Code: "234"; Name: "345"; Code: "456" 'as col from dual)
The select regexp_substr (regexp_substr (col, '[^;] + ', 1, level), [^ :] + ', 1, 2)
The from xx
Connect by level & lt;=regexp_count (col, '[^;] + ')
  • Related