comparison replace_text_in_line.xml @ 7:d64eace4f9f3 draft

Uploaded
author bgruening
date Sat, 17 Jan 2015 08:30:15 -0500
parents 8928e6d1e7ba
children c78b1767db2b
comparison
equal deleted inserted replaced
6:8928e6d1e7ba 7:d64eace4f9f3
7 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement> 7 <requirement type="package" version="4.2.2-sandbox">gnu_sed</requirement>
8 </expand> 8 </expand>
9 <version_command>sed --version | head -n 1</version_command> 9 <version_command>sed --version | head -n 1</version_command>
10 <command> 10 <command>
11 <![CDATA[ 11 <![CDATA[
12 sed 12 sed
13 -r 13 -r
14 --sandbox 14 --sandbox
15 "s/$find_pattern/$replace_pattern/g" 15 "s/$find_pattern/$replace_pattern/g"
16 "$infile" 16 "$infile"
17 > "$outfile" 17 > "$outfile"
18 ]]> 18 ]]>
19 </command> 19 </command>
20 <inputs> 20 <inputs>
21 <param format="txt" name="infile" type="data" label="File to process" /> 21 <param format="txt" name="infile" type="data" label="File to process" />
22 <param name="find_pattern" type="text" size="20" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " > 22 <param name="find_pattern" type="text" size="20" label="Find pattern" help="Use simple text, or a valid regular expression (without backslashes // ) " >
23 <sanitizer> 23 <sanitizer>
24 <valid initial="string.printable"> 24 <valid initial="string.printable">
25 <remove value="&apos;"/> 25 <remove value="&apos;"/>
26 </valid> 26 </valid>
27 </sanitizer> 27 </sanitizer>
89 89
90 ----- 90 -----
91 91
92 **Example 2** 92 **Example 2**
93 93
94 **Find Pattern:** ^(.{4}) 94 **Find Pattern:** ^(.{4})
95 **Replace Pattern:** &\\t 95 **Replace Pattern:** &\\t
96 96
97 Find the first four characters in each line, and replace them with the same text, followed by a tab character. In practice - this will split the first line into two columns. 97 Find the first four characters in each line, and replace them with the same text, followed by a tab character. In practice - this will split the first line into two columns.
98 98
99 99
100 ----- 100 -----
101 101
102 **Extened Regular Expression Syntax** 102 **Extened Regular Expression Syntax**
103 103
104 The select tool searches the data for lines containing or not containing a match to the given pattern. A Regular Expression is a pattern descibing a certain amount of text. 104 The select tool searches the data for lines containing or not containing a match to the given pattern. A Regular Expression is a pattern descibing a certain amount of text.
105 105
106 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for. 106 - **( ) { } [ ] . * ? + \ ^ $** are all special characters. **\\** can be used to "escape" a special character, allowing that special character to be searched for.
107 - **^** matches the beginning of a string(but not an internal line). 107 - **^** matches the beginning of a string(but not an internal line).
108 - **(** .. **)** groups a particular pattern. 108 - **(** .. **)** groups a particular pattern.
109 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern. 109 - **{** n or n, or n,m **}** specifies an expected number of repetitions of the preceding pattern.
110 110
111 - **{n}** The preceding item is matched exactly n times. 111 - **{n}** The preceding item is matched exactly n times.
112 - **{n,}** The preceding item ismatched n or more times. 112 - **{n,}** The preceding item ismatched n or more times.
113 - **{n,m}** The preceding item is matched at least n times but not more than m times. 113 - **{n,m}** The preceding item is matched at least n times but not more than m times.
114 114
115 - **[** ... **]** creates a character class. Within the brackets, single characters can be placed. A dash (-) may be used to indicate a range such as **a-z**. 115 - **[** ... **]** creates a character class. Within the brackets, single characters can be placed. A dash (-) may be used to indicate a range such as **a-z**.
116 - **.** Matches any single character except a newline. 116 - **.** Matches any single character except a newline.
117 - ***** The preceding item will be matched zero or more times. 117 - ***** The preceding item will be matched zero or more times.
118 - **?** The preceding item is optional and matched at most once. 118 - **?** The preceding item is optional and matched at most once.
119 - **+** The preceding item will be matched one or more times. 119 - **+** The preceding item will be matched one or more times.
120 - **^** has two meaning: 120 - **^** has two meaning:
121 - matches the beginning of a line or string. 121 - matches the beginning of a line or string.
122 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets. 122 - indicates negation in a character class. For example, [^...] matches every character except the ones inside brackets.
123 - **$** matches the end of a line or string. 123 - **$** matches the end of a line or string.
124 - **\|** Separates alternate possibilities. 124 - **\|** Separates alternate possibilities.
125 125
126 126
127 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. 127 **Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported.
128 128
129 @REFERENCES@ 129 @REFERENCES@