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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:56:59+00:00 2026-06-09T12:56:59+00:00

I have a message, that counts message reply’s in subject.. the pattern is like

  • 0

I have a message, that counts message reply’s in subject..

the pattern is like this:

RE[22] Some subject

and when person replys to it, it should be:

RE[23] Some subject

So basically I need to get the value between “[” and “]” ( RE[**] ) and change it.. but I can’t just go by length, since it could change, for example, it could be “RE[254]”..

I tried to find solutions with regex or scan but I can’t get this working any way..
I don’t really understand how to do this in ruby.

  • 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-09T12:57:00+00:00Added an answer on June 9, 2026 at 12:57 pm

    Ok, i how it works, thanks to Christoph Petschnig and davidrac

    In the end, what i did was this:

    @string = "RE[22] Kaut kads random teksts..."
    @get_re = nil
    
     @string.sub(/\d+/) do |x|
       @get_re = x.to_i + 1
    end
    

    with cinda did the trick, since my reply number allways would be first, but what if its first message and it dosnt have the RE[] prefix, so i needed to think this furher..

    i modified davidrac example a bit and got the solution. So now it dosnt matter if the @string has the RE[] prefix:

    @string = "RE[25] some random subject with more numbers 245 in it"
    

    or not:

    @string = "some random subject with more numbers 245 in it"
    

    this code will edit or add it:

    @get_re = nil
    
    @string.sub(/(?<=RE\[)\d+(?=\])/) do |x|
        @get_re = @string["RE[#{x.to_i + 1}]"]
    end
    
    return @get_re? @get_re : "RE[1] " + @string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Message.xaml file that should display a recipient field and a message
I'd like to have a commit message cleanup that will not necessarily remove lines
I have a simple contact form with Subject and Message that I want to
I have a dict that looks like this db = { 'ObjectID': ['-1', '6',
I have a jArray and a string from that jArray, message2: [{date:2012,count:1,message : message1},
I have a message that I want to fadeIn when a form is successfully
I have an xml message that is in the older schema (xsd) format. My
I have a html response message that I want to add a link to.
I have a serializable Message class that has a Data As Object property that
I have an NSMutableArray called message that I've alloc'd in init and release 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.