regex ex problem

  • Thread starter Thread starter philipl
  • Start date Start date
P

philipl

hi,

does any one how to do regex to get the charset in this strings?

"SCRIPT language="JavaScript"
charset="ISO-8859-1">..."...."..."...">?"
^^^^^^^^^^
I want the value after charset, (charsets value is not consistant) I
am having problems with the following regexp, I don't know at compile
time what will be after the iso number,I can't seem to be able to
describe the ending conditions, the multiple "s causes too much string
to be returned:

tag = "charset";
Regex r = new Regex(tag+"\\s*=\\s*\"?(.*)\"?");

thx
 
If you're trying to capture the value of the charset
attributes, this will do that:

new Regex(@"charset\s*=\s*\"?([^\"]*)");

Keep in mind this code will find charset anywhere in your
document and return andthing inside of the quotes that
follow. If quotes are optional, you'll have to modify
that regex a bit.

Good luck!

Jerry Negrelli
 
Back
Top