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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:04:11+00:00 2026-05-24T03:04:11+00:00

New to programming and Ruby. I’m working with the iStock API and need to

  • 0

New to programming and Ruby. I’m working with the iStock API and need to send a fileID to request information about files I have.

Example files I have that I need get to request info on iStock:

["iStock_000001053628Small.jpg", "iStock_000002270952Big_Web.mov", "ist2_7034929-blurred-commuter.jpg", iStock_000000042199Medium.jpg] 

Working in irb, the code I send to iStock’s API:

require 'xmlrpc'
parameters = {:apiKey=>"#", :fileID=>"1053628"}
server = XMLRPC::Client.new2( "http://api.istockphoto.com/webservices/xmlrpc")
server.call("istockphoto.image.getInfo", parameters)

Challenge:
I need to extract the fileID numbers out of the array. This means I have to take all the zeros off the front of the file number. However, the file numbers differ in length and the number of zeros in the front differs for each image.

istock.each do |x|
  result = ' '
  x.scan(/\d+/) do |y|
    if y.to_i > 4
      result << y
    end
    puts result
  end
end

000001053628
000002270952
7034929
000000042199

I’m not sure how to approach this problem because if I set up rules for the sets of 0’s, there might be a time when the actual fileID also has these in it.

  • 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-24T03:04:12+00:00Added an answer on May 24, 2026 at 3:04 am

    I am not sure about what different filename formats you have to support, but something like this works for me:

    $ irb
    irb(main):001:0> test_data = ["iStock_*000001053628*Small.jpg", "iStock_000002270952BigWeb.mov", "ist2_7034929-blurred-commuter.jpg", "iStock_*000000042199*Medium.jpg"]
    => ["iStock_*000001053628*Small.jpg", "iStock_000002270952Big Web.mov", "ist2_7034929blurred-commuter.jpg", "iStock_*000000042199*Medium.jpg"]
    irb(main):002:0> test_data.map do |d|
    irb(main):003:1*   d.scan(/\d{4,}/).first.gsub(/^0+/,'')
    irb(main):004:1> end
    => ["1053628", "2270952", "7034929", "42199"]
    irb(main):005:0>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Here's my requisite line about being new to ruby/rails and programming in general; first
I'm pretty new to programming, specifically Ruby and I've been bumping my head working
What are some new and exciting programming languages? I have already looked at ruby
Im very new to programming with ruby on rails. I need to write a
I am new to programming and I have a question about how to pull
Ruby on Rails has become a new competitive face in the server programming industry,
Im new to programming and I dont know very much about but I'm making
I'm a designer and brand new to programming. I have just opened my localhost
I am a new Ruby on Rails user and had a question. I have
I'm new to both Ruby and programming in general. I've been trying to put

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.