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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:24:22+00:00 2026-05-24T20:24:22+00:00

I need a ruby regexp pattern that matches a string containing a letter (for

  • 0

I need a ruby regexp pattern that matches a string containing a letter (for simplicity say ‘a’) n times and then n at the end.

For example, it should match “aaa3”, “aaaa4” etc but not “a2” or “aaa1”, etc.

  • 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-24T20:24:22+00:00Added an answer on May 24, 2026 at 8:24 pm

    That is not possible in regex since it is not a regular language (that’s easy to prove with the Pumping Lemma for Regular Languages). I’m not sure how much more powerful ruby regex is than a true Regular Expression, but I doubt it’s powerful enough for this. You can set a finite limit on it and state each possibility like:

    a1|aa2|aaa3|aaaa4|aaaaa5||aaaaaa6||aaaaaaa7||aaaaaaaa8||aaaaaaaaa9
    

    Since all finite lanugages are regular, but it would be much easy to use string operations to count the number of times a letter appears and then parse for that integer in the string right after the last of that letter.

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

Sidebar

Related Questions

I need a RegEx pattern which matches from where to the end of the
I need to write a little ruby function that does word wrapping. I have
I need to get Ruby on Rails (3.0.9) installed onto a production server that
I need to clip out all the occurances of the pattern '--' that are
Ruby setters—whether created by (c)attr_accessor or manually—seem to be the only methods that need
I have an input string and a pattern. I need to replace each match
Is is possible to create/use a regular expression pattern in ruby that is based
I've got a string that I want to read line-by-line, but I also need
I read about many CSS related languages and tools which need ruby. What is
I have developed a simple library in Ruby and need to use this in

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.