- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 03:14 PM
Has anyone been able to successfully get the Global (/g) switch to work successfully in Pattern Designer for a RegEx parsing strategy?
If I write a pattern that successfully is iterated using the Global switch and it tests correctly in a tool like Regexr, that same pattern won't match on subsequent iterations when I try with /g in the Pattern Designer.
I am trying to build a tabular variable and would like an additional row for each match of the pattern
Thanks!
Sean
Solved! Go to Solution.
- Labels:
-
Discovery
-
Service Mapping

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2018 10:59 PM
Hi,
Unfortunately the global switch is not supported, and the expression matchs each line separately.
The good news are that it is on the road map as a future enhancement.
If you are populating a table it will iterate through the entire text and add new table row for each successful (non global) match.
in order to globally match the entire text, you should write a pattern step with an eval statement and implement a simple java script that will run regexp match with any required flags.
Hope this helps.
If it does please mark if helpful and share your results.
Asi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 10:45 AM
Hey Johnny,
I can suggest 2 approaches this can be done:
1. Simple way: just use an existing string variable inside your eval statement and add delimiter (i.e. ";" or "|") between each match result.
Then it is easy to convert it into a table in another step using delimited text parsing operation.
2. Create a table variable inside your eval statement and then use ctx.setAttribute() function to create it as a context variable.
The exact variable type is dependent in your eval language, and I don't remember the exact type.
If the first approach is not feasible, drop me a message and I'll find out for you.
Asi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2018 02:47 PM
1) if I had a string of these type comma seperated, how would I make a table out of them? I want a table of hosts and ports. "tcp://yaddahost:1829,tcp://yaddahost2:1822"
2)a javascript example of creating a table structure from scratch would be amazing. I believe the structure is an ArrayList of HashMaps. They are quite fragile and they break easily, from what I'm seeing. I get a .toString() value of the ArrayList if I make the slightest booboo in handling it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 04:31 AM
//this almost works - What I'm not able to do yet,
//is add a row (HashMap) to the table (ArrayList)
//this code causes the pattern step to spin and spin
//any tips on how to adjust this would be appreciated
var rtrn = '';
var jms_conn = ${jms_connections};
//the mistake is here - don't call .size() within the
//for loop that you add a row within - derp derp
for (var i=0; i < ${jms_connections}.size(); i++){
var hmap = jms_conn.get(i);
var mapped = hmap.get('values')+'';
if (mapped.indexOf(',') > 1){
var parts = mapped.split(',');
var myMap = hmap.clone();
myMap.put('new_header', parts[1]);
jms_conn.add(myMap);
myMap = hmap.clone();
myMap.put('new_header', parts[0]);
jms_conn.add(myMap);
} else {
hmap.put('new_header', mapped);
}
jms_conn.remove(i);
}
//rtrn = jms_conn;
CTX.setAttribute("tmp2", jms_conn);
rtrn = jms_conn.size();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2018 11:50 AM
//got it - this actually works
var jms_conn = ${jms_connections};
var orig_size = ${jms_connections}.size();
for (var i=0; i < orig_size; i++){
var hmap = jms_conn.get(i);
var mapped = hmap.get('values')+'';
if (mapped.indexOf(',') > 1){
var parts = mapped.split(',');
//put this part back
hmap.put('new_header', parts[1]+'');
//make a new row for the other part
var myMap = new Packages.java.util.LinkedHashMap(hmap);
myMap.put('new_header', parts[0]+'');
jms_conn.add(myMap);
} else {
//provide the orig value in this new column
hmap.put('new_header', mapped);
}
}
CTX.setAttribute("tmp2", jms_conn);