ruby - Trying to change last to "x"s to 23 -


i have been playing around irb , have string looks this:

irb(main):072:0> puts ["[\"4354 5432 5432 xxxxx\", \"6547 6547 8543 xxxxx\", \"2344 6543 6674 xxxxx\", \"2346 6236 7543 xxxxx\", \"1273 5585 5587 xxxxx\"]"] => nil irb(main):073:0>  

what want gsub last 2 "x"s of each 17 digit combination, 23.

what i've tried far (i've been using rubular):

  • a.gsub(/\d[x]/,"23") <= grabs "x"s i'm close
  • a.gsub(/\w[x{2}]/,"23") <= grabs "x"s grabs two digits each combination.

is there easier way i'm not understanding?

a.gsub(/\d{4} \d{4} \d{4} xxx\kxx/, '23') 

\d{4} = 4 digits

what \k drop matched far. can use don't replace entire number, still able validate have in desired format.


Comments

  1. Finden Sie das perfekte Thema fรผr Ihre WordPress-Site. Wรคhlen Sie aus Tausenden atemberaubender wordpress themes deutsch.

    ReplyDelete
  2. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these, I have new and perfect site Slot. Thank you very much.

    ReplyDelete
  3. This page contains the necessary information about game. From here I am get some information.Have
    you played the famous akinator unblocked
    ? If not, you must play it today only as it is a quite amazing game which will give you some fun moments playing it in your busy day schedule

    ReplyDelete
  4. This page contains the necessary information The Samsung Galaxy M52 is going to be published very soon if you feel free you can visit my site Samsung M52 Release Date

    ReplyDelete
  5. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these, I have new and perfect site buy lsd online. Thank you very much.

    ReplyDelete
  6. What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these, I have new and perfect site asesoria inmobiliaria. Thank you very much.

    ReplyDelete
  7. We are very satisfied with Shiftbase because all of our employees can easily see their schedule in the mobile app and they can specify their availability! Also, the customer service is very helpful and responds quickly to all our questions. ๐Ÿ‘Œ๐Ÿ‘Œ schedule maker
    ๐Ÿ‘Œ๐Ÿ‘Œ You can quickly and easily make a schedule for your team in the main menu of the Shiftbase under ‘Schedule’. On the left side, you will see the names of the employees and at the top, you will see the dates.

    ReplyDelete
  8. I am continually amazed by the amount of information available on this subject.What you presented was well researched and well worded in order to get your stand on this across to all your readers lithium ion forklift battery charger.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -