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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:11:53+00:00 2026-06-14T12:11:53+00:00

I have a sentence with a uniform structure that I would like to use

  • 0

I have a sentence with a uniform structure that I would like to use regex to pick out certain words from the sentence. For example the sentence structure is as follows:

["Take the"] + [train] + ["bound train to"] + [stop]

where words in quotes are hard coded and words without quotes are variable. For example, based on that sentence structure, the following sentences are applicable:

- Take the L bound train to 1st street.
- Take the 1 bound train to neverland. 

I need help coming up with a regex pattern that would match against this and allow me to parse out the [train] and [stop]. My regex kunfu is weak, and I could use some help.

  • 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-14T12:11:54+00:00Added an answer on June 14, 2026 at 12:11 pm

    Very simple regexp: '^Take the (.*) bound train to (.*)\.$' that stores [train] in the first capture group and [stop] in the second.

    ^               # Match the start of the string
    Take the        # Match the literal string
    (.*)            # Capture the [train]
    bound train to  # Match the literal string
    (.*)            # Capture the [stop]
    \.              # Match the fullstop 
    $               # Match the end of string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sentence (this is a dumb example sentence ) that looks like
I have a sentence like this : Stan, Stanley, Stan! I would like to
I have this regex on mongodb query to match words by prefix: {sentence: new
I have a sentence like 'This is [[a captured group]].' The number of words
I have a sentence that looks like this: what is this? i want this
I have a sentence like: Name: JOHN J. SMITH Sometag: How would I grab
I have sentence like Q 000 1111 00001 0001 00 //SOME_STRING I wanted to
I have a sentence structure along the lines of [word1]{word2} is going to the
I have a sentence like this. 1       2     3
I have a varargs constructor like this : public class Sentence { public String[]

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.