Search and Replace

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
hjack
Posts: 26
Joined: Mon Apr 17, 2006 3:06 am
Location: Kentucky

Search and Replace

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Search | Replace... (<F8>):
Find what: </?checkbox[^>]*>
Replace with: [nothing]

[X] Regular expression

Replace All
hjack
Posts: 26
Joined: Mon Apr 17, 2006 3:06 am
Location: Kentucky

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
hjack
Posts: 26
Joined: Mon Apr 17, 2006 3:06 am
Location: Kentucky

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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...)
hjack
Posts: 26
Joined: Mon Apr 17, 2006 3:06 am
Location: Kentucky

Post by hjack »

Well, Ben, as usual your brain and fast response has saved me a lot of work. Again, I appreciate your help.

Jack
Post Reply