comparison regex_switch.xml @ 0:8da8330208f4 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/regex_switch commit 502f06ff9cb9edd0eceaba726b2cc848757e34dd
author iuc
date Thu, 09 Oct 2025 08:39:02 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8da8330208f4
1 <tool name="Regex switch" id="regex_switch" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" tool_type="expression">
2 <description>boolean from regex on element identifier</description>
3 <macros>
4 <token name="@TOOL_VERSION@">1.0.0</token>
5 <token name="@VERSION_SUFFIX@">0</token>
6 </macros>
7 <expression type="ecma5.1"><![CDATA[{
8 var name = $job.input.name;
9 var pat = $job.pattern;
10 var matched = false;
11
12 try {
13 var re = new RegExp(pat);
14 matched = re.test(name);
15 } catch (e) {
16 return { "__error_message": "Invalid regular expression: " + (e && e.message ? e.message : String(e)) };
17 }
18
19 return { "matched": matched, "unmatched": !matched };
20 }]]></expression>
21 <inputs>
22 <param name="input" type="data" format="data"
23 label="Dataset" />
24 <param name="pattern" sanitize="false" type="text" label="Regex pattern"
25 help="Example: \.csv$">
26 <sanitizer>
27 <valid>
28 <add preset="string.printable"/>
29 </valid>
30 </sanitizer>
31 <validator type="empty_field" message="Please enter a regular expression."/>
32 </param>
33 </inputs>
34 <outputs>
35 <output type="boolean" name="matched" from="matched" label="Match result"/>
36 <output type="boolean" name="unmatched" from="unmatched" label="Unmatched result"/>
37 </outputs>
38 <tests>
39 <test expect_num_outputs="2">
40 <param name="input" value="sample.csv" ftype="txt"/>
41 <param name="pattern" value="\.csv$"/>
42 <output name="matched" value_json="true"/>
43 <output name="unmatched" value_json="false"/>
44 </test>
45
46 <test expect_num_outputs="2">
47 <param name="input" value="table.tsv" ftype="txt"/>
48 <param name="pattern" value="\.csv$"/>
49 <output name="matched" value_json="false"/>
50 <output name="unmatched" value_json="true"/>
51 </test>
52 </tests>
53 <help><![CDATA[
54 **Regex switch**
55
56 Matches a regular expression against the name of the input file. It emits two booleans:
57 `matched` (the match result) and `unmatched` (its negation). Connect either to a step's **Conditionally skip step?** input.
58
59 **Regex syntax reference:** https://262.ecma-international.org/16.0/index.html#sec-patterns
60 ]]></help>
61 </tool>