troubleshooting scripts

Hello again,

I would like to test some HTML in a test script against various regex patterns.

The final script will process session variables, but when I paste HTML into
session.setVariable("variable",value) the script chokes due to the presence of numerous " and other special characters.

How do I manually setup a variable with all those characters?

Also, once the session variable is created, can I "get" it in the same script?

Best regards,

M

I'm not really sure I follow,

I'm not really sure I follow, so bear with me.

If you want to test the raw HTML in a script, you wouldn't need a session variable. Just something like

content = scrapeableFile.getContentAsString();

if (content.matches(yourRegEx))
{
   something = true;
}

Wouldn't that do?

Thank you!

This
content = scrapeableFile.getContentAsString();
is very helpful.

I had use method .matcher instead of .matches to find a match
and the following worked well.

Edit: I did not realize I could use ".*exactPattern.*" which would make .matches
work as intended.

Thank you again.
P.S.I have another question. I'll start a new thread.

import java.util.regex.Pattern;
import java.util.regex.Matcher;

String LINE_END = System.getProperty("line.separator");
content = scrapeableFile.getContentAsString();

stringToSearch = content;
Pattern p = Pattern.compile("dida");
Matcher m = p.matcher(stringToSearch);

if (m.find()) {
session.log( LINE_END );
session.log("FOUND!");
session.log( LINE_END );
}