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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:11:06+00:00 2026-06-17T16:11:06+00:00

I have a string of text and within it are several instances that are

  • 0

I have a string of text and within it are several instances that are always a hash and then a number (and then sometimes punctuation), eg:

Text #12321, Text #456 Text #789; Text #0! Etc.

I need regex to preg_match_all every number (variable lengths) following a hash but before anything not a number – so in the above example I’d get an array of:

‘12321‘ ‘456‘ ‘789‘ ‘0‘

I tried:

'/[#](.*?)[^0-9]/'

and

'/(\\d+)(.*?)(\\d+)/'

but the first failed in a bizarre way and the second only matches every other instance.

I’m trying to puzzle my way through documentation but it would help so much to see how best to do this. Could anyone save a me hours of confusion and tell me the correct regex syntax for this?

  • 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-17T16:11:07+00:00Added an answer on June 17, 2026 at 4:11 pm

    Use this regex: –

    '/#(\d+)/'
    

    You don’t need to check for non-number at the end. \d+ will only get you digits anyways, and will stop as soon as a non-digit is encountered.

    Note that # is not a meta character in regex, so you don’t need to enclose it in a character class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several applications within my domain that accept similar inputs in text fields.
I have a text file that have strings enclosed within double-quotes. I want to
I have a string of text that contains html, and I need to extract
Suppose I have a string of text, of all characters Latin-based. With punctuation. How
I have a text string that has been doctored to be web safe URLs
I have a string with nested groups like this ('blabla' is some text within
Is it possible to have multiple formatting of a text string within a single
I have a JTextPane and I have some text within that JTextPane. However, because
I have string: text and something and something like f213 @@ -1,9 +1,11 @@
I have a string like: hello #this# is #some text string# text text I

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.