|
14 | 14 | -r |
15 | 15 | --sandbox |
16 | 16 | #for $replacement in $replacements: |
| 17 | + -e '$replacement.sed_options' |
17 | 18 | -e |
18 | 19 | 's/$replacement.find_pattern/$replacement.replace_pattern/g' |
19 | 20 | #end for |
|
47 | 48 | <add source="'" target="'"'"'" /> |
48 | 49 | <add source="/" target="\/"/> |
49 | 50 | </mapping> |
50 | | - |
51 | 51 | </sanitizer> |
52 | | - |
53 | | - </param> |
| 52 | + </param> |
| 53 | + <param name="sed_options" type="text" size="20" optional="true" label="Additional sed commands before replacement" help="Provide additional sed commands before the replacement (e.g., ':a;N;$!ba;')." > |
| 54 | + <sanitizer> |
| 55 | + <valid initial="string.printable"> |
| 56 | + <remove value="'"/> <!-- Removes single quotes --> |
| 57 | + <remove value="/"/> <!-- Removes slashes --> |
| 58 | + </valid> |
| 59 | + <mapping initial="none"> |
| 60 | + <add source="'" target="'"'"'" /> <!-- Escapes single quotes --> |
| 61 | + <add source="/" target="\/"/> <!-- Escapes slashes --> |
| 62 | + </mapping> |
| 63 | + </sanitizer> |
| 64 | + </param> |
54 | 65 | </repeat> |
55 | 66 | </inputs> |
56 | 67 | <outputs> |
|
59 | 70 | <tests> |
60 | 71 | <test> |
61 | 72 | <param name="infile" value="replace_text_in_line1.txt" /> |
62 | | - <param name="find_pattern" value="CTC." /> |
63 | | - <param name="replace_pattern" value="FOOBAR" /> |
| 73 | + <repeat name="replacements"> |
| 74 | + <param name="find_pattern" value="CTC." /> |
| 75 | + <param name="replace_pattern" value="FOOBAR" /> |
| 76 | + <param name="sed_options" value="" /> |
| 77 | + </repeat> |
64 | 78 | <output name="outfile" file="replace_text_in_line_results1.txt" /> |
65 | 79 | </test> |
66 | 80 | <test> |
67 | 81 | <param name="infile" value="replace_text_in_line1.txt" /> |
68 | 82 | <repeat name="replacements"> |
69 | 83 | <param name="find_pattern" value="CTC." /> |
70 | 84 | <param name="replace_pattern" value="FOOBAR" /> |
| 85 | + <param name="sed_options" value="" /> |
71 | 86 | </repeat> |
72 | 87 | <repeat name="replacements"> |
73 | 88 | <param name="find_pattern" value="chr" /> |
74 | 89 | <param name="replace_pattern" value="domain" /> |
| 90 | + <param name="sed_options" value="" /> |
75 | 91 | </repeat> |
76 | 92 | <output name="outfile" file="replace_text_in_line_results2.txt" /> |
77 | 93 | </test> |
| 94 | + <test> |
| 95 | + <param name="infile" value="replace_text_in_line1.txt" /> |
| 96 | + <repeat name="replacements"> |
| 97 | + <param name="find_pattern" value="\n" /> |
| 98 | + <param name="replace_pattern" value="" /> |
| 99 | + <param name="sed_options" value=":a;N;$!ba" /> |
| 100 | + </repeat> |
| 101 | + <output name="outfile" file="replace_text_in_line_results3.txt" /> |
| 102 | + </test> |
78 | 103 | </tests> |
79 | 104 | <help> |
80 | 105 | <![CDATA[ |
@@ -155,7 +180,9 @@ The select tool searches the data for lines containing or not containing a match |
155 | 180 | - **\|** Separates alternate possibilities. |
156 | 181 |
|
157 | 182 |
|
158 | | -**Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. |
| 183 | +**Note**: SED uses extended regular expression syntax, not Perl syntax. **\\d**, **\\w**, **\\s** etc. are **not** supported. However, you can use SED FAQ to perform commands using special characters. |
| 184 | + More complex options can look like `sed -e '$!N;s/foo/bar/;'`. Here, `$!N;` is an optional part which you only need to set in very special cases. The `foo` part is the search string, and the `bar` part is the replacement string. |
| 185 | + Please read the SED FAQ here: https://www.pement.org/sed/sedfaq3.html#s3.2 |
159 | 186 |
|
160 | 187 | ]]> |
161 | 188 | </help> |
|
0 commit comments