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 7887365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:33:40+00:00 2026-06-03T05:33:40+00:00

I am trying to extract phone numbers from a string in php using the

  • 0

I am trying to extract phone numbers from a string in php using the preg_match_all() function. I know that this pattern '!\d+!' extracts all numbers. But i need it to do more.
The numbers i want to extract either start with 256 followed by 9 numbers or 078,077,071,079 followed by 8 numbers.
Thank you.

  • 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-03T05:33:42+00:00Added an answer on June 3, 2026 at 5:33 am

    Try this:

    \b(?:256\d{9}|07[17-9]\d{8})\b
    

    Explanation:

    <!--
    \b(?:256\d{9}|07[17-9]\d{8})\b
    
    Options: ^ and $ match at line breaks; free-spacing
    
    Assert position at a word boundary «\b»
    Match the regular expression below «(?:256\d{9}|07[17-9]\d{8})»
       Match either the regular expression below (attempting the next alternative only if this one fails) «256\d{9}»
          Match the characters “256” literally «256»
          Match a single digit 0..9 «\d{9}»
             Exactly 9 times «{9}»
       Or match regular expression number 2 below (the entire group fails if this one fails to match) «07[17-9]\d{8}»
          Match the characters “07” literally «07»
          Match a single character present in the list below «[17-9]»
             The character “1” «1»
             A character in the range between “7” and “9” «7-9»
          Match a single digit 0..9 «\d{8}»
             Exactly 8 times «{8}»
    Assert position at a word boundary «\b»
    -->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to extract phone number in java from the given String i.e.
Trying to extract strings that are wrapped in double brackets. For example [[this is
I am trying to extract some info from a website using simple_html_dom. Currently I
hi i'm trying to extract values from this tagged file here is the file
I am trying to extract an XML node from a URI reference. This URI
im trying to extract an info hash from a torrent magnet link using perls
I am trying to extract the value from a textarea using jquery, but my
I am trying to extract a link using xpath from the below mentioned url
I am trying to extract a date from a string variable and was hoping
I am trying to extract telephone word numbers from free text. The general format

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.