Randall Fairman wrote:
There are a zillion ways to do this. What have you tried?
Maybe your question is really an issue with JMeter. Sorry, but I can' t help you there.
Campbell Ritchie wrote:
. . . and welcome to the Ranch
Agustin Perez wrote:It's not a JMeter question because I know the problem is with me.. I haven't learned very well how regex works and now I'm paying the price.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Agustin Perez wrote:It's not a JMeter question because I know the problem is with me.. I haven't learned very well how regex works and now I'm paying the price.
To be honest, unless your requirement is very simple (eg, to remove only the first and last tag in a line or a file, regardless of the situation), I doubt whether regex is what you want. HTML is hierarchical, and regexes are lousy for hierarchical structures.
Agustin Perez wrote:That's my requirement, I only need to remove the opener tag (<div class="whatever">) and the closing tag (</div>).
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Agustin Perez wrote:That's my requirement, I only need to remove the opener tag (<div class="whatever">) and the closing tag (</div>).
Right, but what if the tag isn't a <div>? Do you still want to remove it? And what if the first and last tags don't match? I think you need to get ALL the rules sorted out before you try anything.
Winston
Agustin Perez wrote:
Here i paste you some of the code I tryed to use to remove the first&last tags.
// Create the pattern
Pattern pattern = Pattern.compile("</?\w+(\s*([a-zA-Z]+=".+")*)*\s*/?>");
// create Matcher from patron
Matcher fit = pattern.matcher(cont);
String result = fit.replaceFirst("");
result = replaceLast(result, '</?\w+(\s*([a-zA-Z]+=".+")*)*\s*/?>', "");
System.out.println("result!!!" + result);
this.content = cont;
I founded the regex browsing the web, but it doesn't work for me... or I couldn't make it work
I only need to remove the first and last Tag like the example on the previous post, just that.
Send me some light please.
Agustin Perez wrote:I found the target tags using the library htmlunit with XPaths.
For example: to find the <div class='ads'> I will write the Xpath ( //div[@class='ads'] ) and using this:
It writes all the div tags with the class='ads' (verified )
Agustin Perez wrote:I found the target tags using the library htmlunit with XPaths.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Agustin Perez wrote:I found the target tags using the library htmlunit with XPaths.
I'm not familiar with that lib, but I suspect you will still want to convert to XHTML before you run your check (I'm pretty sure it's a requirement for XPath, so perhaps htmlunit already does). The problem with regular HTML is that
(a) It doesn't require all tags to be closed.
(b) It allows overlapping tags.
Conversion to XHTML will solve both of those issues.
Winston
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |