I have to replace BLANKS in an XML-content. The XML-File looks like this:
...
<element id="zlnr">T0379885</element>
</datarow>
<dataset id="tbl_ZM_tabelle">
<datarow>
<element id="knre1">AT</element>
<element id="knre2">U 14291808</element>
<element id="dreieck">false</element>
<element id="betrag">986</element>
</datarow>
<datarow>
<element id="knre1">GB</element>
<element id="knre2"> 615 5511 59</element>
<element id="dreieck">false</element>
<element id="betrag">254</element>
</datarow>
<datarow>
<element id="knre1">NL</element>
<element id="knre2">812 915422 B01</element>
...
In all lines with the element "knre2" the BLANKS in the following content should be deleted. I tried to use the following macro:
Start Recording:
- Key: F5 -> Find "knre2"
- Key: Strg G -> Goto Column39 (with extend selection)
- Key: F8 -> Replace [:BLANK:] with nothing (Scope: Selected text)
- Key: ESC
- Key: Arrow down
- Key: Pos1
Stop Recording
During recording this works fine, but when playing back the cursor moves correct, but no changes are made.
Perhaps it would be better to use regular expressions, but how ?
Deleting following spaces in current line
Moderators: AmigoJack, bbadmin, helios, MudGuard
-
HansemannX
- Posts: 2
- Joined: Fri Jan 25, 2008 7:25 am
- Location: Germany
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
That won't have worked either while recording the macro or while playing it back. The regular expression for a white space character is [[:blank:]], not [:blank:]. (Look in TextPad's help under Reference Information | Regular Expressions | Character Class Operators.) With that correction, your macro works.
You can't do this with a single repeated regular expression replacement. After each replacement, the cursor moves beyond the replaced text, and the context that should restrict the next search has now passed.
But, if your source isn't too long, you can perform this repetitive replacement repeatedly until it beeps:
You can't do this with a single repeated regular expression replacement. After each replacement, the cursor moves beyond the replaced text, and the context that should restrict the next search has now passed.
But, if your source isn't too long, you can perform this repetitive replacement repeatedly until it beeps:
This assumes you are using Posix regular expression syntax:Find what: (<element id="knre2">.*)[[:blank:]](.*</element>)
Replace with: \1\2
[X] Regular expression
Replace All
Configure | Preferences | Editor
[X] Use POSIX regular expression syntax
-
HansemannX
- Posts: 2
- Joined: Fri Jan 25, 2008 7:25 am
- Location: Germany