Search and Delete
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Search and Delete
I have a series of lines, each containing different words, which I want to delete. Example:
<start>john doe</start>
<start>Fred Jones</start>
<start>David Sylvester Smith</start>
Can someone please help a rookie understand how I can replace all of the above names, leaving the following:
<start></start>
<start></start>
<start></start>
Thanks
Jack
<start>john doe</start>
<start>Fred Jones</start>
<start>David Sylvester Smith</start>
Can someone please help a rookie understand how I can replace all of the above names, leaving the following:
<start></start>
<start></start>
<start></start>
Thanks
Jack
Search and delete
Thanks, Andrew. So simple when you talk to experts.
search and delete
Andrew, or others, another 'simple' problem.
In my xml app, I need to change the following:
<checkbox element="cc;john doe" label
<checkbox element="cc;bill adams" label
<checkbox element="cc;ron howard" label
to
<checkbox label
<checkbox label
<checkbox label
Can you help me with this?
Thanks
Jack
In my xml app, I need to change the following:
<checkbox element="cc;john doe" label
<checkbox element="cc;bill adams" label
<checkbox element="cc;ron howard" label
to
<checkbox label
<checkbox label
<checkbox label
Can you help me with this?
Thanks
Jack
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
search and delete
Ben, this works for most of the elements, but there is another problem.
<checkbox element="cc;john Doe" id-type"xx" label
<checkbox element="fred jones " id-type"xx" label
I want to replace the characters and quotations in the first example leaving the id-type"xx" label. As you suggested, .* replaces all characters to label (which works in my original problem, but deletes id-type="xx")
In the second example, there is no cc; and therefore I want this particular element to be ignored.
Probably clear as mud. In essence, if the element complex contains the cc; I want to delete element="cc;xxxx" to the id-type"xx" label. If there is no cc; I want it to be left alone.
Again, your help, knowledge, and time are very much appreciated.
Jack
<checkbox element="cc;john Doe" id-type"xx" label
<checkbox element="fred jones " id-type"xx" label
I want to replace the characters and quotations in the first example leaving the id-type"xx" label. As you suggested, .* replaces all characters to label (which works in my original problem, but deletes id-type="xx")
In the second example, there is no cc; and therefore I want this particular element to be ignored.
Probably clear as mud. In essence, if the element complex contains the cc; I want to delete element="cc;xxxx" to the id-type"xx" label. If there is no cc; I want it to be left alone.
Again, your help, knowledge, and time are very much appreciated.
Jack
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
Something like this should do it, for lines with or without the id-type bit, but only if there's a "cc;..." bit:
This assumes you are using Posix regular expression syntax:Find what: <checkbox element="cc;[^"]*" ((id-type".*" )?label)
Replace with: <checkbox \1
[X] Regular expression
Replace All
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
search and replace
Thanks, Ben. This works on most lines, but I have now found several lines as below:
<checkbox element="cc;xxx" id="xxxxx xx" id-type="xx" label
<checkbox element="cc;xxx" id-type="xx" id="xxxx xxx xx" label
I am unclear how to modify your expression to delete these extra id's.
Thanks
Jack
<checkbox element="cc;xxx" id="xxxxx xx" id-type="xx" label
<checkbox element="cc;xxx" id-type="xx" id="xxxx xxx xx" label
I am unclear how to modify your expression to delete these extra id's.
Thanks
Jack
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
search and delete
As usual, Ben, you are very perceptive. That is just what I am trying to avoid. Here is a typical series in my app:
<checkbox element="cc;xxx" id="xxx xxx" id-type="x" label
<checkbox element="xxx;xx" id="xxx xxxx xxx xx" id-type="x" label
<checkbox element="xxx;xx" id="xx xxxx xx xxx" id-type="x" label
<checkbox element="xxx;xx" id-type="x" id="xxx xxxx xxx xx" label
<checkbox element="cc;xxxx" id-type="x" id="xxxxx xx" label
I want to delete the 'element="cc"xxx" in line 1, leave lines 2,3,and 4 intact, and delete the 'element=cc;xxxx" in line 5. Note that in some lines, the id-type and id= are reversed in order. In my apps, all id's and id types must stay intact. This result is ultimately what I am trying to achieve:
<checkbox id="xxx xxx" id-type="x" label
<checkbox element="xxx;xx" id="xxx xxxx xxx xx" id-type="x" label
<checkbox element="xxx;xx" id="xx xxxx xx xxx" id-type="x" label
<checkbox element="xxx;xx" id-type="x" id="xxx xxxx xxx xx" label
<checkbox id-type="x" id="xxxxx xx" label
Again, thanks. I have over 350 occurrences of the cc; in each of 5 different apps, so this would be a major assistance to me.
Jack
<checkbox element="cc;xxx" id="xxx xxx" id-type="x" label
<checkbox element="xxx;xx" id="xxx xxxx xxx xx" id-type="x" label
<checkbox element="xxx;xx" id="xx xxxx xx xxx" id-type="x" label
<checkbox element="xxx;xx" id-type="x" id="xxx xxxx xxx xx" label
<checkbox element="cc;xxxx" id-type="x" id="xxxxx xx" label
I want to delete the 'element="cc"xxx" in line 1, leave lines 2,3,and 4 intact, and delete the 'element=cc;xxxx" in line 5. Note that in some lines, the id-type and id= are reversed in order. In my apps, all id's and id types must stay intact. This result is ultimately what I am trying to achieve:
<checkbox id="xxx xxx" id-type="x" label
<checkbox element="xxx;xx" id="xxx xxxx xxx xx" id-type="x" label
<checkbox element="xxx;xx" id="xx xxxx xx xxx" id-type="x" label
<checkbox element="xxx;xx" id-type="x" id="xxx xxxx xxx xx" label
<checkbox id-type="x" id="xxxxx xx" label
Again, thanks. I have over 350 occurrences of the cc; in each of 5 different apps, so this would be a major assistance to me.
Jack
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
search and delete
Ben, sorry about any ambiguity. This works fine. I do sincerely appreciate your help, as it has saved me about 5 hours of work and frustration.