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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Regex in C# 4
Regex woes 8
Regex help needed 1
regex multiplication problem 3
Regex help 1
Regex Replace. Comma and Dot in Number 2
How to get rid of the regex???? 6
Regex - Matching URLS 2

Back
Top