dcole.ath.cx Posted April 30, 2006 Share Posted April 30, 2006 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 More sharing options...
justsomeguy Posted May 1, 2006 Share Posted May 1, 2006 Are you looking for any tag, or specifically for those meta tags?And why only one? Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted May 1, 2006 Author Share Posted May 1, 2006 I want someone to write me a pattern to find any meta tag.and I only want one because it's a pattern.. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 2, 2006 Share Posted May 2, 2006 In that case, all you need is a case-insensitive pattern that finds "<meta ... >", right? That's not difficult to write, are you looking for something more specific? Link to comment Share on other sites More sharing options...
dcole.ath.cx Posted May 2, 2006 Author Share Posted May 2, 2006 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 More sharing options...
Little Goat Posted May 2, 2006 Share Posted May 2, 2006 the php function get_meta_tags('pathtofile');returns an array containing all the meta tags of the file you specify.LG Link to comment Share on other sites More sharing options...
justsomeguy Posted May 2, 2006 Share Posted May 2, 2006 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now