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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:13:32+00:00 2026-05-22T21:13:32+00:00

I have a similar problem, to a previously asked question. But similar practices apparently

  • 0

I have a similar problem, to a previously asked question. But similar practices apparently do not produce similar results.

Previous Question

New question – I want to match the lines beginning in T as the first match, and the following lines beginning with X as the second match (as a whole string, to be later matched by another regex)

What I have so far is (^T(\d+)\n(.*?)(?:the_problem)/m) I don’t know what to replace “the_problem” with, or even if that is the issue. I assumed some rendition (?:\n|\z), but apparently not. Everything I tried, would not count the next occurrence of ^T(\d+) as the start of a new group, and continue to capture all of the lines between each occurrence, at the same time.

Sample text;
T01C0.025
T02C0.035
T03C0.055
T04C0.150
T05C0.065
T06C0.075
%
G05
G90
T01
X011200Y004700
X011200Y009700
X018500Y011200
X013500Y-011200
X023800Y019500
T02
X034800Y017800
X-033800Y-017800
X032800Y017800
T03
X036730Y003000
X038700Y003000
X040668Y-003000
X059230Y003000
T04
X110580Y017800
X023800Y027300
X095500Y028500
X005500Y-006500
X021500Y-006500
T05
X003950Y002000
X003950Y004500
X003950Y007000
T06
X026300Y027300
M30

I only want to capture the shorter version of T01, T02,…T0n, not the longer version at the top, then the entire collection of ^X(-?\d+)Y(-?\d+) that follows it, as another match.

Result 1.
Match 1. T01
Match 2. X011200Y004700
         X011200Y009700
         X018500Y011200
         X013500Y-011200
         X023800Y019500

Result 2.         
Match 1. T02
Match 2. X034800Y017800
         X-033800Y-017800
         X032800Y017800

Result 3.         
Match 1. T03
Match 2. X036730Y003000
         X038700Y003000

         ....etc....

Thanks in advance for any help 😉 Note: I prefer to use raw Ruby, without extensions or plugins. My version of ruby is 1.8.6.

  • 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-05-22T21:13:32+00:00Added an answer on May 22, 2026 at 9:13 pm

    Try this instead:

    ^(T[^\s]+)[\n\r\s]((?:(?:X\S+)[\n\r\s])+)
    

    It makes the groups for the X lines into non-capturing groups, then puts all the repetitions of the final pattern into a single group. All the X lines will be in a single capture.

    You can test this using Rubular (an indispensable tool for developing regular expressions) http://rubular.com/r/PRnurKy64Q

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

Sidebar

Related Questions

I have a problem similar to this question which was previously asked but my
I have asked a similar question previously but it was never resolved so here
I have previously solved a similar problem in this question , where I asked
This problem is similar to my previously asked question. When I query data using
I've had a similar question but the answer did not entirely fix my problem.
I have posted a question on here previously asking similar advise, but this project
I have similar problem to one discussed here , but with stronger practical usage.
I suppose similar problem would have been discussed here, but I couldn't find it.
I have a similar problem as a previously solved problem of mine, except this
I know similar questions (regarding cherry-picking) have been asked before, but I haven't really

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.