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

  • SEARCH
  • Home
  • 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 7984411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:15:40+00:00 2026-06-04T11:15:40+00:00

I know strlen is used to determine the string length – but is it

  • 0

I know strlen is used to determine the string length – but is it possible to search an entire block of text and pull out strings that are exactly 8 characters long?

  • 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-06-04T11:15:42+00:00Added an answer on June 4, 2026 at 11:15 am

    The following assumes by “strings exactly eight characters long” you mean “words”, e.g. in a text like

    $blockOfText = <<< TXT
    codepad is an online compiler/interpreter, and a simple collaboration tool.
    Paste your code below, and codepad will run it and give you a short URL you 
    can use to share it in chat or email. 
    TXT;
    

    you want to find the word “compiler” only.


    Non-Regex solution (demo):

    print_r(
        array_filter(
            str_word_count($blockOfText, 1),
            function($word) { return strlen($word) === 8; }
        )
    );
    

    Reference:

    • str_word_count — Return information about words used in a string
    • array_filter — Filters elements of an array using a callback function
    • Callbacks
    • Anonymous Functions

    Regex solution (demo):

    preg_match_all(
        '(
            \b     # match from a word boundary
            \w{8}  # followed by exactly 8 "word" characters
            \b     # followed by a word boundary
        )x', 
        $blockOfText, 
        $matches
    );
    print_r($matches[0]);
    

    A “word” character is any letter or digit or the underscore character, that is, any character which can be part of a Perl “word”. The definition of letters and digits is controlled by PCRE’s character tables, and may vary if locale-specific matching is taking place. For example, in the “fr” (French) locale, some character codes greater than 128 are used for accented letters, and these are matched by \w.

    Reference:

    • preg_match_all — Perform a global regular expression match
    • PCRE Pattern Syntax
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know it's possible to overflow ordinary code: char string[9]; scanf(%s, string). But is
Know this might be rather basic, but I been trying to figure out how
This might sound a bit dumb but am confused. I know the strlen() would
Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know that it's a subject that can raise a lot of debate, but
I know this is fairly subjective, but I'm diving into testing and learning about
Anyone know if it is possible to make the PeriodicalUpdater pass the data it
I know this is largely an opinion, but I'm interested if you have one
I have a void * , call it data , whose length I know,
Here's what I have so far: string stripSymbols(string str) { int stringSize = strlen(str.c_str());

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.