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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:55:47+00:00 2026-06-04T00:55:47+00:00

Here’s what I try to do : isNumeric(right(trim(contract_id),1)) isNumeric right trim contract_id 1 isNumeric(right(trim(contract_id),1),

  • 0

Here’s what I try to do :

isNumeric(right(trim(contract_id),1))

isNumeric
    right
        trim
            contract_id
        1

isNumeric(right(trim(contract_id),1), bob, george(five(four, two)))

isNumeric
    right
        trim
            contract_id
        1
    bob
    george
        five
            four
            two

So basiclly it take a line (let’say trim(var)) and will make an array of it (array(trim => array(var)).

I did try with regex and strpos but no result… I need help. Thanks.

  • 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-04T00:55:49+00:00Added an answer on June 4, 2026 at 12:55 am

    First off a descent parser will always give you better control.
    A whole regex solution might enable you to skip errors or at least let you continue
    and not crap out.

    Your format is extremely simple, and an engine that can do internal recursion could at
    least get you an outter match. Using language recursion, you could re-enter that regex
    enabling you to parse the core.

    I’m no php expert, but if it supports regex recursion and language level eval() you
    will be able to inject an array construct into the source text.
    Then eval the string to create an nested array image, complete with parameters.

    I actually converted your text to an array in about 12 lines of Perl, but added to
    it when it got interresting.

    Here is a Perl sample. Its dumbed down so its readable. It might give you some inspiration to try it in php (if it can do these things). Like I said I’m no php expert.

      use Data::Dumper;
    
      my $str = '
        asdf("asg")
        isNumeric(right(trim(contract_id),1))
        var = \'aqfbasdn\'
        isNumeric(right(trim ( ,contract_id,),-1, j( ) ,"  ", bob, george(five(four, two))))
      ';
    
      my $func      = '\w+';           # Allowed characters (very watered down)
      my $const     = '[\w*&^+-]+';
      my $wspconst  = '[\w*&^+\s-]+';
    
      my $GetRx = qr~
        \s*
        (                       # 1 Recursion group
           (?:
               \s* ($func) \s* 
               [(]
                  (?:  (?> (?: (?!\s*$func\s*[(] | [)] ) . )+ ) 
                     | (?1)                                         
                  )*                                               
               [)]
           )
         )                                                 
      ~xs;
    
      my $ParseRx = qr~
        (                        # 1 Recursion group
           (?:
               \s* ($func) \s*                                    # 2 Function name
               [(]
               (                                                  # 3 Function core
                  (?:  (?> (?: (?!\s*$func\s*[(] | [)] ) . )+ ) 
                     | (?1)                                         
                  )*                                               
               )                                                   
               [)]
                                             # OR..other stuff
                                             # Note that this block of |'s is where               
                                             # to put code to parse constants, strings,
                                             # delimeters, etc ... Not much done, but
                                             # here is where that goes.
                                             # -----------------------------------------
             |  \s*["'] ($wspconst) ["']\s*      # 4,5 Variable constants
             | \s* ($const) \s* 
                                             # Lastly, accept empty parameters, if
             | (?<=,)                        # a comma behind us,
             | (?<=^)(?!\s*$)                # or beginning of a new 'core' if actually a paramater.
           )       
         )                                                 
      ~xs;
    
    ##
      print "Source string:\n$str\n";
      print "=======================================\n";
      print "Searching string for functions ...\n";
      print "=======================================\n\n";
    
    
      while ($str =~ /$GetRx/g) {
          print "------------------\nParsing:\n$1\n\n";
          my $res = parse_func($1);
          print "String to be eval()'ed:\n$res\n\n";
    
          my $hashref = eval $res.";";
          print "Hash from eval()'ed string:\n", Dumper( $hashref ), "\n\n";
      }
    
    ###
      sub parse_func
      {
          my ($core) = @_;
          $core =~ s/$ParseRx/ parse_callback($2, $3, "$4$5") /eg;
          return $core;
      }
    
      sub parse_callback
      {
          my ($fname, $fbody, $fconst) = @_;
          if (defined $fbody) {
              return "{'$fname'=>[" . (parse_func( $fbody )) . "]}";
          }
          return "'$fconst'"
      }
    

    Output

    Source string:
    
        asdf("asg")
        isNumeric(right(trim(contract_id),1))
        var = 'aqfbasdn'
        isNumeric(right(trim ( ,contract_id,),-1, j( ) ,"  ", bob, george(five(four, two))))
    
    =======================================
    Searching string for functions ...
    =======================================
    
    ------------------
    Parsing:
    asdf("asg")
    
    String to be eval()'ed:
    {'asdf'=>['asg']}
    
    Hash from eval()'ed string:
    $VAR1 = {
              'asdf' => [
                          'asg'
                        ]
            };
    
    
    ------------------
    Parsing:
    isNumeric(right(trim(contract_id),1))
    
    String to be eval()'ed:
    {'isNumeric'=>[{'right'=>[{'trim'=>['contract_id']},'1']}]}
    
    Hash from eval()'ed string:
    $VAR1 = {
              'isNumeric' => [
                               {
                                 'right' => [
                                              {
                                                'trim' => [
                                                            'contract_id'
                                                          ]
                                              },
                                              '1'
                                            ]
                               }
                             ]
            };
    
    
    ------------------
    Parsing:
    isNumeric(right(trim ( ,contract_id,),-1, j( ) ,"  ", bob, george(five(four, two))))
    
    String to be eval()'ed:
    {'isNumeric'=>[{'right'=>[{'trim'=>['' ,'contract_id','']},'-1',{'j'=>[ ]} ,'  ','bob',{'george'=>[{'five'=>['four','two']}]}]}]}
    
    Hash from eval()'ed string:
    $VAR1 = {
              'isNumeric' => [
                               {
                                 'right' => [
                                              {
                                                'trim' => [
                                                            '',
                                                            'contract_id',
                                                            ''
                                                          ]
                                              },
                                              '-1',
                                              {
                                                'j' => []
                                              },
                                              '  ',
                                              'bob',
                                              {
                                                'george' => [
                                                              {
                                                                'five' => [
                                                                            'four',
                                                                            'two'
                                                                          ]
                                                              }
                                                            ]
                                              }
                                            ]
                               }
                             ]
            };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my scenario: <!-- Normal Control --> <div class=required> <label for=address1>Address line 1</label> <input
Here is my code, which takes two version identifiers in the form 1, 5,
Here is my code...I have two dimensional matrices A,B. I want to develop the
here are 2 screen shots when i try to debug my code in visual
Here a simple question : What do you think of code which use try
here is code: <script type=text/javascript> function doit(){ $('table td').each(function () { if ($(this).text().trim() !=
Here's my proposed (very simplified to illustrate the problem space) design for a C#
Here the total height of all <div> 's are 900 pixels, but the jQuery
Here is a complete example. I want to forbid using A::set from objects casted
Here's the deal: I'm in the process of planning a mid-sized business application that

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.