Page 1 of 1

Search and Replace

Posted: Sun Jan 23, 2011 11:01 pm
by hjack
I need to find each of the following and replace each complex with nothing (blank):

<checkbox label="abc" id="1234" separator=''>
</checkbox>

<checkbox label="abc" id="xyz" separator=''>
</checkbox>

<checkbox label="abc" id="wz23" separator=''>
</checkbox>

Your help is appreciated.

Jack

Posted: Mon Jan 24, 2011 7:53 am
by ben_josephs
Search | Replace... (<F8>):
Find what: </?checkbox[^>]*>
Replace with: [nothing]

[X] Regular expression

Replace All

Posted: Sat Feb 05, 2011 8:09 pm
by hjack
Ben, thank you. I have another similar request:

I need to remove the following first statement and replace it with [nothing], but I want to keep the second statement: (The ids are differentiated by text and quotations. I want to keep the statement which has the quotations)

<checkbox label="abc" id='xxyxx' separator=" ">
</checkbox>

<checkbox label="abc" id="abcxxx" separator=" ">
</checkbox>

Jack

Posted: Sun Feb 06, 2011 12:58 pm
by ben_josephs
That is not clear. But I think you want something like
Find what: <checkbox [^>]*id='[^']*'[^>]*>\n</checkbox>\n
Replace with: [nothing]

[X] Regular expression

Replace All

Posted: Sun Feb 06, 2011 5:40 pm
by hjack
Ben, after I re-read my statement, it was unclear-sounding to me. Here is specifically what I want:

I have several lines of xml code which contain an id statement enclosed with ' '. I have others which contain an id statement enclosed with " ".

Examples:
<checkbox element="severity;hpi" label="Chills" id-type="6" id='associated chills ... ' separator=" "><start>There are <b>chills.</b> </start></checkbox>

<checkbox element="severity;hpi" label="Chills" id-type="6" id="associated chills post ..." separator=" "><start>There are <b>chills.</b> </start></checkbox>

The content within the id is different for each statement. I want to remove any statement with the label "Chills" which also contains an id that is delineated with ' ', without affecting or removing the statement with the label "Chills" which contains an id that is delineated with " ".

As always, I appreciate and thank you for your help.

Jack

Posted: Sun Feb 06, 2011 6:11 pm
by ben_josephs
Find what: <checkbox [^>]*label="Chills" [^>]*id='[^']*'[^>]*>.*</checkbox>\n
Replace with: [nothing]

[X] Regular expression

Replace All
This will only work if each checkbox element is entirely on one line and if there is only one checkbox element on any line.

(The choice of element as an attribute name for an element may lead to confusion...)

Posted: Sun Feb 06, 2011 7:05 pm
by hjack
Well, Ben, as usual your brain and fast response has saved me a lot of work. Again, I appreciate your help.

Jack