Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 649463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:56:48+00:00 2026-05-13T21:56:48+00:00

I’m completely new to regular expressions, and I need to filter all the words

  • 0

I’m completely new to regular expressions, and I need to filter all the words of at least 3 characters (and a maximum size of 16) out of a text. (so I can enter those data into a MySQL database)

Currently, everything works, except for the regular expression:

/^.{3,16}$/

(I constructed this from a tutorial found using Google 😉 )

Thanks!
Yvan

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 (yeah, I know – it’s kind of sloppy – this is only used to generate the queries…)

<?php
    //regexer.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) {
            //print_r($match);
            echo ("INSERT INTO maf_codes (Code, GameID) VALUES ('$match', %GAMEID%);\n");
        }
    }
?>

Found a solution: replace the $_REQUEST[‘regex’] with the regex did work 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:56:49+00:00Added an answer on May 13, 2026 at 9:56 pm

    Try this:

    /\b\w{3,16}\b/
    

    Explained:

    • \b matches a word boundary
    • \w matches a word character
    • {3,16} applies to the \w and it indicates that at least 3 and at most 16 characters should be matched.

    FYI: I omitted the start anchor (^) and end anchor ($) from the regex you noted in your question because it seems like you want to find matches with longer strings of text as input and the anchors would restrict the matching to only instances where the entire input string matched.

    UPDATE:

    Here is the proof that this regex works:

    <?php
    
    $input = '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';
    
    $matches = array();
    
    preg_match_all('/\b\w{3,16}\b/', $input, $matches);
    
    print_r($matches);
    
    ?>
    

    Outputs:

    Array
    (
        [0] => Array
            (
                [0] => rjm1986
                [1] => SinuhePalma
                [2] => excel2010
                [3] => Jimineedles
                [4] => 209663603
                [5] => C6A7XR
                [6] => Snojog
                [7] => XmafiaX
                [8] => Cival2
                [9] => HitmanPirrie
                [10] => MAX
                [11] => 4163016
                [12] => Dredd23
                [13] => Daddy420
                [14] => mattpauley
                [15] => Mykillurdeath
                [16] => 244833585
                [17] => KCKnight
                [18] => Greystoke
                [19] => Fatbastard
                [20] => Fucku4
                [21] => Davkar
                [22] => Banchy2
                [23] => ET187
                [24] => Slayr69
                [25] => Nik1236
                [26] => SeriousAl
                [27] => 315791
                [28] => 216996334
                [29] => K1ra
                [30] => Koops1
                [31] => LastFallout
                [32] => zmileben
                [33] => bismark
                [34] => Krlssi
                [35] => FuckOff1
                [36] => 1owni
                [37] => Ulme
                [38] => Rxtvjq
                [39] => halfdeadman
                [40] => Jamacola
                [41] => LBTG1008
                [42] => toypark
                [43] => Magicman6497
                [44] => Tyboe187
                [45] => Bob187
                [46] => Zetrox
            )
    
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I have a reasonable size flat file database of text documents mostly saved in
I need to clean up various Word 'smart' characters in user input, including but
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.