Jump to content

finding tags in a script


dcole.ath.cx
 Share

Recommended Posts

Please read all of this before responding!How would you write a needle for finding the following<meta name="Robots" content="index,follow" /><meta name="Keywords" content="blah blah blah"><meta name='description' CONTENT='lalalala'><meta name='ROBOTS' CONTENT='ALL'><META NAME='ROBOTS' CONTENT='ALL'>I'm searching a script and I don't know if there using HTML or XHTML so I need to account for bothThey may or may not be using capsThey may be using single or double quotesthe name and content could equal anythingThis may only be one needle (search string)so it needs to use metacharacters, quantifers, and character classes!

Link to comment
Share on other sites

that's what I'm looking for, I don't know how to do the case-insensitive partwould I just do [Mm] or something, then [Ee] or is there an easier way, if this [Mm] way would even work.

Link to comment
Share on other sites

Well it's probably easier if you just looked up a regexp reference. Here is the PHP reference:http://www.php.net/manual/en/reference.pcr...tern.syntax.phpI don't remember the syntax either, so when I'm answering this I'm looking everything up, it's something you could easily do yourself.How about something like this. You enclose the whole thing in delimiters, and include a caseless modifier so that it is case-insensitive.//iThat's a start. Then you want to match the literal string '<meta', so add that/<meta/iThen you need 0 or more characters after that. So add that./<meta*/iThen it ends with a closing >, so add that./<meta*>/iAnd voila. That wasn't so hard.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...