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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:04:52+00:00 2026-06-13T10:04:52+00:00

This is my first experience with pattern matching using regular expressions so any help

  • 0

This is my first experience with pattern matching using regular expressions so
any help is appreciated.

I am trying to search a string for the following substrings:

"(TPU 1-999)
http://somewebaddress.com"

I want to keep TPU, 1-999 and the link as separate substrings.

This is the pattern I am using:

^\s{3}\(([AEINPRSTUW]{3})\s(\d{1,3}.\d{2,5})\)$^\s{3}(http+\s{1,100})$

I’ll break it down to explain my reasoning

^\s{3} – beginning of string (or line in this case), followed by 3 spaces

\( – left parentheses

([AEINPRSTUW]{3}) – 3 instances of any of the letters in brackets, TPU being one example

\s(\d{1,3}.\d{2,5}) – a space and then 1-3 numeric digits, separated by any char from 2-5 more numeric digits

\)$ – right parentheses, end of line

^\s{3} – beginning of next line followed by three spaces

(http+\s{1,100})$ – the characters “http” followed by anywhere between 1 and 100 non whitespace characters, and the end of the line.

This pattern doesn’t work right now but am I headed in the right direction?

  • 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-13T10:04:53+00:00Added an answer on June 13, 2026 at 10:04 am

    $^ this cannot work. $ is the end of line (before the line break), ^ is the beginning of a line (after the line break). But the line break is a character (or two), while do not advance the position of the regex engine. So $ and ^ try to match the same position, which can only ever happen if they are the ending and beginning of an empty line – and even then putting them in this order would be greatly misleading. If you want to make sure that there is exactly one line break between them try this:

    ^\s{3}\(([AEINPRSTUW]{3})\s(\d{1,3}.\d{2,5})\)$(\r\n?|\n)^\s{3}(http+\S{1,100})$
    

    However, as ridgerunner pointed out the comment, the following \s{3} could match (up to 3) more linebreaks, since they are whitespace as well.

    Also note that . as a separator of your numbers might not be the best idea. At least, use a non-digit character:

    ^\s{3}\(([AEINPRSTUW]{3})\s(\d{1,3}\D\d{2,5})\)$(\r\n?|\n)^\s{3}(http+\S{1,100})$
    

    Note also that I have changed your last \s to \S (because \s is whitespace, \S is non-whitespace).

    Also note, that the string you have shown us does not contain those three whitespaces you are trying to match. So making them optional (as CaptainMurphy suggested) might be helpful, too:

    ^\s*\(([AEINPRSTUW]{3})\s(\d{1,3}\D\d{2,5})\)$(\r\n?|\n)^\s*(http+\S{1,100})$
    

    And since we are already matching that line break, we could also remove those anchors there completely, they do not really help any more:

    ^\s*\(([AEINPRSTUW]{3})\s(\d{1,3}\D\d{2,5})\)(\r\n?|\n)\s*(http+\S{1,100})$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a web system using regular PHP. This was my first experience with
This is a homework assignment and my first experience using RegEx. I am starting
This is my first experience in programming with Python and I'm trying to log
This is my first experience with EF so I'm probably doing something stupid. Any
I have no experience with regular expressions and would love some help and suggestions
This is my first experience with javascript, and... Well... Ugh. Here's what's happening: function
This is my first post and I my first experience with jquery. I have
Using Dozer to map two objects, I have: /** /* This first class uses
#include <iostream> using namespace std; // This first class contains a vector and a
I am following this example (First comment), How to create a custom ListView with

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.