I am completely new to regular expressions and I need to filter out all words with at least 3 characters (and a maximum size of 16) from the text. (so I can enter this data into the MySQL database)
Everything currently works, except for the regular expression:
/^.{3,16}$/
(I built it from a tutorial found using Google ;-))
Thank! Ivan
Sample data:
rjm1986 * SinuhePalma * excel2010 * Jimineedles * 209663603 * C6A7XR * Snojog * XmafiaX * Cival2 * HitmanPirrie * MAX * 4163016 * Dredd23 * Daddy420 * mattpauley * Mykillurdeath * 244833585 * KCKnight * Greystoke * Fatbastard * Fucku4 * Davkar * Banchy2 * ET187 * Slayr69 * Nik1236 * SeriousAl * 315791 * 216996334 * K1ra * Koops1 * LastFallout * zmileben * bismark * Krlssi * FuckOff1 * 1owni * Ulme * Rxtvjq * halfdeadman * Jamacola * LBTG1008 * toypark * Magicman6497 * Tyboe187 * Bob187 * Zetrox
PHP Code (yes, I know - this is careless - this is only used to generate requests ...)
<?php
$text = @$_REQUEST['fText'];
if ($text == '') {
?>
<form method="post" action="">
<input type="text" name="regex" />
<textarea name="fText"></textarea>
<br />
<input type="submit"></input>
</form>
<?php
} else {
preg_match_all($_REQUEST['regex'], $_REQUEST['fText'], $matches);
header ("Content-type: text/plain");
foreach ($matches as $match) {
echo ("INSERT INTO maf_codes (Code, GameID) VALUES ('$match', %GAMEID%);\n");
}
}
?>
Found solution: replace $ _REQUEST ['regex'] with regular expression;)
source
share