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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:15:36+00:00 2026-05-21T21:15:36+00:00

I use YAML to get MySQL schema and i need to parse only these

  • 0

I use YAML to get MySQL schema and i need to parse only these kind of strings CHAR(60) or VARCHAR(90) etc..

Parsing result would be like this:

array('CHAR', 60);
array('VARCHAR', 90);
  • 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-21T21:15:37+00:00Added an answer on May 21, 2026 at 9:15 pm

    The following regex will do it. If these don’t occur one per line, you should also add the \b boundaries after the opening slash and before the closing one.

    $s = "VARCHAR(90)";
    $matches = array();
    preg_match("/([A-Z]+)\(([0-9]+)\)/", $s, $matches);
    
    // Then use the matched values into your array.
    array($matches[1], $matches[2]);
    

    EDIT: Had the $matches array keys wrong the first time. Should be 1 & 2, not 0 & 1.

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

Sidebar

Related Questions

I am trying to use Google App Engine's app.yaml to automatically serve *.html files
I'm making a gem for internal use. In it, I load some YAML from
I'm trying to use YAML to create list of all stored procs used in
While integrating backgroundrb-rails3 I get the following error, ~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at
I tried to get rvm uninstalled in order to use rbenv on my Mac.
When I run the below script I get Can't use an undefined value as
When I run the below script I get a corrupt yaml file like so
I have a YAML file of groups that I would like to get into
I would like to use file locking on yaml files, but how do I
I want to get an array from a yaml file inside one of my

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.