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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:13:46+00:00 2026-05-24T01:13:46+00:00

I have a gitmodules file like this: [submodule dotfiles/vim/bundle/cucumber] path = dotfiles/vim/bundle/cucumber url =

  • 0

I have a gitmodules file like this:

[submodule "dotfiles/vim/bundle/cucumber"]
path = dotfiles/vim/bundle/cucumber
url = git://github.com/tpope/vim-cucumber.git
[submodule "dotfiles/vim/bundle/Command-T"]
path = dotfiles/vim/bundle/Command-T
url = git://github.com/vim-scripts/Command-T.git

What I want to do is to for each submodule get path and url as a hash or other structure which will keep data like:

submodule: cucumber (path -> ‘path’, url -> ‘url’)

How can I do it with regex? Or maybe there is more efficient way of parsing this kind of files?

  • 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-24T01:13:47+00:00Added an answer on May 24, 2026 at 1:13 am

    This file format is something of a standard and so I imagine there is a gem or other code floating around that will parse it. On the other hand, it’s easy to parse and encapsulated little text problems like this are “the fun part” of development, so why not reinvent the wheel? It’s kind of like playing a game…

    require 'pp'
    
    def scangc
      result = h = {}
      open '../.gitconfig', 'r' do |f|
        while s = f.gets
          s.strip!
          if s[0..0] == '['
            result[s[1..-2].to_sym] = h = Hash.new
            next
          end
          raise 'expected =' unless s['=']
          a = s.strip.split /\s+=\s+/
          h[a[0].to_sym] = a[1]
        end
      end
      pp result
    end
    
    scangc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the .gitmodule file have the list of submodule url and path, similar to this
Currently I am trying to clone this git repo: https://github.com/twilio/OpenVBX into my main repo,
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
I have a project that has a submodule at lib/three20 My .gitmodule file looks
I would like to change the directory name of a Git submodule in my
I have a git repository set up with several submodules, which creates a .gitmodules
Have you managed to get Aptana Studio debugging to work? I tried following this,
Have you seen library for flexible working with terminal(Unix like)? I want to implement
Have a look at the menus on this page: http://www.pieterdedecker.be/labs/vspwpg/?page_id=96 They look okay 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.