Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
finding elements in the report with Regular expression
ShlomiW
<p>Hi all,</p><p> </p><p>I would like to know if there is any way to look for an element in the report without knowing it's exact name or ID.</p><p>maybe to use Regular expression or something like that?</p><p> </p><p>for example:</p><p>I have a report parameter that has the value "1"</p><p>in this case I want to drop all the elements that has "1" in there name.</p><p> </p><p>So, if I have the following items in my report</p><p>Grid: name = 1 - first grid</p><p>Grid: name = 1 - second grid</p><p>Grid: name = 2 - first grid</p><p> </p><p>the first 2 item will be dropped, because they have "1" in their name and the third element will stay in the report.</p>
Find more posts tagged with
Comments
BlazK
<p>I am trying to do something simmilar by using dataset filter. You can write an expression and I am trying to put regex into that filter (for the regex use param).</p><p> </p><p>I do not know if this works because I am trying it right now, so if you manage to do it please tell us how.</p>
kclark
<p>You could use regex to do something like this. I'm not sure if this is the best approach but I'm not sure if there's another way. You could create a java class then jar it and use it in the beforeFactory() of your report. Here's one example of how to do this</p><pre class="_prettyXprint">public class Regex { static String readFile(String path, Charset encoding) throws IOException { byte[] encoded = Files.readAllBytes(Paths.get(path)); return encoding.decode(ByteBuffer.wrap(encoded)).toString(); } public static void main(String[] args) throws IOException { String rptdesign = readFile("C:/Users/kclark/bex-dev/bex-dev/someReport.rptdesign", StandardCharsets.UTF_8); String pattern1 = "id=""; String pattern2 = """; Pattern p = Pattern.compile(Pattern.quote(pattern1) + "(.*?)" + Pattern.quote(pattern2)); Matcher m = p.matcher(rptdesign); while (m.find()) { System.out.println(m.group(1)); } }}</pre><p>If you look at the xml source you can look to see what tags you want to get your data from and modify the above code to return what you need.</p>