Hello, I am not very good with regular expressions, so I was wondering if someone could write some code that will:
<!-- Being Logged_in -->
I want a regular expression that will find the above even if the Logged_in varible is something else. It will only be letters upper/lower case and underscores.
Thanks.
Assuming there's a file called woo.txt with that string somewhere inside. You could do this:
<?php $woo = file_get_contents('woo.txt'); ereg("<!-- Being (.*) -->", $woo, $yay); echo $yay[0]; ?>
That would return the first result found. Have fun.
Eeeewww! Ereg functions = bad! Preg functions = good!
$pattern = '/<!-- [a-z_]+? -->/i'; // $pattern will work with any preg_ function
EDIT: Read my next post!
Slight fix to bradgrafelman's pattern:
/<!-- [a-z_]+? -->/i
sighs My attempt to beat ereg... fizzled!
As Weedpacket pointed out, I forgot the '+' (pattern should repeat 1 or more times) and the '?' (non-greedy character? what's the actual name for this? lol) characters in my pattern. Bad me!