Home > database >  Oracle regular expression to replace specific label and inside content
Oracle regular expression to replace specific label and inside content

Time:10-04

Now oracle database with HTML tags in a certain field of string, and now want to take style="display: none" label and replace the content of the inside is empty characters, and great god teach some labels may be nested with style="display: none" attribute, string the following
A: string & lt; p> Excuse me, excuse me, excuse me, & lt; Span _fck_bookmark="1" style="display: none" & gt; & NBSP party and & lt; Span _fck_bookmark="1" style="display: none" & gt; & NBSP party and for the case plan China & lt;/span> In plan China & lt;/span> Scheme and as a Mr Assad & lt;/p>
Should be replaced as follows:
String B: & lt; p> Excuse me, excuse me, excuse me, & lt; Span _fck_bookmark="1" style="display: none" & gt; & NBSP party and for the case plan China & lt;/span> Scheme and as a Mr Assad & lt;/p>

Replacement should be: excuse me, excuse me, excuse me,
scheme and as a Mr Assad
Could you tell me how to write great god regular type should be? Can replace many times will now display the take out, in the replacement label

CodePudding user response:

SQL> The select regexp_replace (regexp_replace (' & lt; p> Excuse me, excuse me, excuse me, & lt; Span _fck_bookmark="1" style="display: none" & gt; Party and & lt; Span _fck_bookmark="1" style="display: none" & gt; Plan China party and case & lt;/span> In plan China & lt;/span> Scheme and as a Mr Assad & lt;/p> ', '& lt; Span _fck_bookmark="1" style="display: none" & gt; . * & lt;/span> ', ' '), '& lt; }. {1, 2 & gt; ', ' ')
2 the from dual;

REGEXP_REPLACE (REGEXP_REPLACE (' & lt; P
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Excuse me, excuse me, could you please tell me,
scheme and as a Mr Assad

CodePudding user response:

reference 1st floor sych888 response:
SQL> The select regexp_replace (regexp_replace (' & lt; p> Excuse me, excuse me, excuse me, & lt; Span _fck_bookmark="1" style="display: none" & gt; Party and & lt; Span _fck_bookmark="1" style="display: none" & gt; Plan China party and case & lt;/span> In plan China & lt;/span> Scheme and as a Mr Assad & lt;/p> ', '& lt; Span _fck_bookmark="1" style="display: none" & gt; . * & lt;/span> ', ' '), '& lt; }. {1, 2 & gt; ', ' ')
2 the from dual;

REGEXP_REPLACE (REGEXP_REPLACE (' & lt; P
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Excuse me, excuse me, could you please tell me, scheme and as a Mr Assad

Hello, this is still a little problem
1, if there are also other attributes in the tag with the display what should I do;
2, if there are other span tags but no display properties will also be removed,

Credit, & lt; Span _fck_bookmark="1" style="display: none" & gt; & nbsp; & nbsp; & nbsp; Plan & lt; Span> 123 & lt; Span _fck_bookmark="1" style="display: none" & gt; & nbsp; & nbsp; & nbsp; Plan & lt; Span> 123 & lt; Span _fck_bookmark="1" style="display: none" & gt; & nbsp; & nbsp; & nbsp; Plan & lt; Span> 123123 & lt;/span> Solution party & amp; nbsp; Party & lt;/span> 123 & lt;/span> Solution party & amp; nbsp; Party & lt;/span> 123 & lt;/span> Solution party & amp; nbsp; Party & lt;/span> Plan & lt; Span> In its 1122 & lt;/span> Its elements: adjusted accordingly when zong & lt;/p>

CodePudding user response:

What do you want to achieve the result?
You'd better put the content and result list
Best can provide the INSERT statement

CodePudding user response:

The
reference 3 floor sych888 response:
what do you want to achieve?
You'd better put the content and result list
It is best to provide the INSERT statement

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Hello
My specific needs is to:
This tag and label content is replaced with an empty
And when have multilayer nested, such as:
Content content & lt;/span> . Along with the replace
Before you provide methods can achieve, but also the content of & lt; Span> The content & lt;/span> To replace the empty,
I want to achieve only replace & lt; Span _fck_bookmark="1" style="display: none" & gt; The contents of the label and tag
If & lt; Span> Label without style=display attributes do not replace


  • Related