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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:56:16+00:00 2026-06-10T18:56:16+00:00

I am using an application that allows the use of a regex to control

  • 0

I am using an application that allows the use of a regex to control the naming of entities.

I have a bunch of entities named like this (each line is the whole name):

Subsystem - CPU - Utilisation [1x]
Subsystem - CPU - Utilisation [2x]
Subsystem - CPU - Utilisation [4x]
Subsystem - CPU - Queue Length
Subsystem - Disk - Space
Subsystem - Disk - Capacity

And I need to use the regex to turn each one into this:

CPU \n Utilisation
CPU \n Queue Length
Disk \n Space
Disk \n Capacity

(the spaces around the \n are for clarity, and not in the real output)

The regex I’m using for that is:

Find:     ^Subsystem - (.*) - (.*)( \[.*\])$
Replace:  ${1}\n${2}

Which works for the ones with a [something] part, but not those without.

Essentially, I need to get part1 and part2, where part2 is terminated either by [ or the end of the line.

  • 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-10T18:56:18+00:00Added an answer on June 10, 2026 at 6:56 pm

    This regex should get you the matches:

    ^Subsystem - ([^\s-]+) - ([^\s\[]+)(?=(?:\s\[)|$).*$
    

    Tested at this Rubular link

    Edit:
    Updated to include “Queue Length”

    ^Subsystem - ([^\s-]+) - (.+?)(?=(?:\s+\[)|$).*$
    

    Tested at this Rubular link

    Breakdown:

    • ^Subsystem - :self explanatory, matching the first few constant chars
    • ([^\s-]+) :capturing group of a negative charset, basically that matches anything until it hits a space or a hyphen
    • (.+?)(?=(?:\s+\[)|$) :Positive lookahead to match anything (non-greedily) that is always followed by EITHER spaces and “[” OR end of line. The ?: is a non-capturing group so that it does not match it.
    • .*$ :match anything else until end of line
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails application that allows searches using longitude and latitude. I have
I'm using: Hibernate MySQL jBoss I have to create an application that allows user
I'm working on an application that allows the user to send a file using
I am currently working on an application that allows reverse geocoding using silverlight +
I have an mvc application that I allow businesses to log in using https://storea.mydomain.com
I have an application that I restart at 2 am every morning using Application.Restart();
I am working on a YouTube web application that allows the user to use
I have a client that would like to add a feature to their application
I have an application that allows users to upload images. The test case I
We have an application that allows the user to add custom columns to our

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.