Topic
  • 10 replies
  • Latest Post - ‏2014-02-24T10:09:23Z by KBSri
KBSri
KBSri
104 Posts

Pinned topic I need to extract only the part of the module name if the folder name is "Sample"

‏2014-02-19T09:16:25Z |

Hi all,

I need to extract the part of the module name if the folder is "Sample"

E.g: Sample is the folder and it located in various projects.It has the module names as "FL_PAR_Sample_Req", "FL_VMC_Smaple_Req".

I need only the part of the module name.

The output string should be PAR and VMC.

Any help is appreciated.

  • adevicq
    adevicq
    154 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-19T09:45:48Z  

    Hi,

    Try something like this:

    Regexp r = regexp "FL_(.*)_Sample_Req"
    string s[] = {
    "FL_PAR_Sample_Req", 
    "FL_VMC_Sample_Req",
    "FL_PAR_xyz_Req"
    }
    
    
    int i 
    for (i = 0; i < sizeof(s); ++i) {
    if (r s[i]) {
        print s[i] ":" s[i][match 1] "\n"
    }
    else
            print s[i] ":" "no match" "\n"
    
    }
    

    Regards

  • KBSri
    KBSri
    104 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-19T09:47:55Z  
    • adevicq
    • ‏2014-02-19T09:45:48Z

    Hi,

    Try something like this:

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">Regexp r = regexp "FL_(.*)_Sample_Req" string s[] = { "FL_PAR_Sample_Req", "FL_VMC_Sample_Req", "FL_PAR_xyz_Req" } int i for (i = 0; i < sizeof(s); ++i) { if (r s[i]) { print s[i] ":" s[i][match 1] "\n" } else print s[i] ":" "no match" "\n" } </pre>

    Regards

    Thanks a ton :)

  • KBSri
    KBSri
    104 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-20T13:16:47Z  
    • KBSri
    • ‏2014-02-19T09:47:55Z

    Thanks a ton :)

    Hello,

    I got stuck up here .The matched string is printing in the DXL window but i am not able to export to the EXCEL sheet for the specific array index.

    nstats[2] = str_domain_name[idomain_name][match 1 is not holding the value consecutively.It is able to hold only the last index value.In this case domain is printing only "MP" as a matched one.

    int idomain_name
            
                string str_domain_name[] = {"FL_PAR_Sample_Req", "FL_VMC_Sample_Req","FL_MP_Sample_Req"}
                
                if(domain == "Components")
                {
                    for (idomain_name = 0; idomain_name < sizeof(str_domain_name); idomain_name++)
                    {
                        if (re_component_domain_name str_domain_name[idomain_name])
                        {
                            print str_domain_name[idomain_name] ":" str_domain_name[idomain_name][match 1] "\n"
                            nstats[2] = str_domain_name[idomain_name][match 1]
                        }
                        else
                        {
                            print str_domain_name[idomain_name] ":" "No match!!" "\n"
                            //nstats[2] = domain
                        }
                    }
                }

     

    Any help would be great

  • adevicq
    adevicq
    154 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-20T14:22:33Z  
    • KBSri
    • ‏2014-02-20T13:16:47Z

    Hello,

    I got stuck up here .The matched string is printing in the DXL window but i am not able to export to the EXCEL sheet for the specific array index.

    nstats[2] = str_domain_name[idomain_name][match 1 is not holding the value consecutively.It is able to hold only the last index value.In this case domain is printing only "MP" as a matched one.

    int idomain_name
            
                string str_domain_name[] = {"FL_PAR_Sample_Req", "FL_VMC_Sample_Req","FL_MP_Sample_Req"}
                
                if(domain == "Components")
                {
                    for (idomain_name = 0; idomain_name < sizeof(str_domain_name); idomain_name++)
                    {
                        if (re_component_domain_name str_domain_name[idomain_name])
                        {
                            print str_domain_name[idomain_name] ":" str_domain_name[idomain_name][match 1] "\n"
                            nstats[2] = str_domain_name[idomain_name][match 1]
                        }
                        else
                        {
                            print str_domain_name[idomain_name] ":" "No match!!" "\n"
                            //nstats[2] = domain
                        }
                    }
                }

     

    Any help would be great

    Hi,

    If you do successively

    nstat[2] = "a"
    nstat[2] = "b"
    nstat[2] = "c"
    

    the value stored in nstat[2] will be "c". I don't know what you expect but if you want to store all the values you must have as many entries in your array as needed.

    Alain

     

  • KBSri
    KBSri
    104 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-20T16:51:18Z  
    • adevicq
    • ‏2014-02-20T14:22:33Z

    Hi,

    If you do successively

    <pre class="html dw" data-editor-lang="js" data-pbcklang="html" dir="ltr">nstat[2] = "a" nstat[2] = "b" nstat[2] = "c" </pre>

    the value stored in nstat[2] will be "c". I don't know what you expect but if you want to store all the values you must have as many entries in your array as needed.

    Alain

     

    Exactly. It is storing the last value of the array index.

     

    Can you please suggest me how to proceed in this case. My requirement is that all the matched values must be stored in the nstat[2]. Fo example: ACS,PAR,MP all the matched values should be stored in the nstats[2].

    Please help me out.

  • adevicq
    adevicq
    154 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-20T16:54:21Z  
    • KBSri
    • ‏2014-02-20T16:51:18Z

    Exactly. It is storing the last value of the array index.

     

    Can you please suggest me how to proceed in this case. My requirement is that all the matched values must be stored in the nstat[2]. Fo example: ACS,PAR,MP all the matched values should be stored in the nstats[2].

    Please help me out.

    In this case you need to concatenate the values (with a separator; a comma for example):

    nstat[2] = nstat[2] "," str_domain_name[idomain_name][match 1]
     

  • KBSri
    KBSri
    104 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-21T12:50:49Z  
    • adevicq
    • ‏2014-02-20T16:54:21Z

    In this case you need to concatenate the values (with a separator; a comma for example):

    nstat[2] = nstat[2] "," str_domain_name[idomain_name][match 1]
     

    Yes i tried this.But in this case I am getting the 0,ACS,PAR,MP in the same EXCEL Value CELL.

     

  • Mike.Scharnow
    Mike.Scharnow
    238 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-21T13:34:23Z  
    • KBSri
    • ‏2014-02-21T12:50:49Z

    Yes i tried this.But in this case I am getting the 0,ACS,PAR,MP in the same EXCEL Value CELL.

     

    So, what do you want? Your code example does not contain anything about a connection to Excel.
    This totally depends on the way your "nstats" variable is evaluated later.

    BR,
    Mike

  • llandale
    llandale
    3035 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-21T17:25:47Z  
    • KBSri
    • ‏2014-02-20T13:16:47Z

    Hello,

    I got stuck up here .The matched string is printing in the DXL window but i am not able to export to the EXCEL sheet for the specific array index.

    nstats[2] = str_domain_name[idomain_name][match 1 is not holding the value consecutively.It is able to hold only the last index value.In this case domain is printing only "MP" as a matched one.

    int idomain_name
            
                string str_domain_name[] = {"FL_PAR_Sample_Req", "FL_VMC_Sample_Req","FL_MP_Sample_Req"}
                
                if(domain == "Components")
                {
                    for (idomain_name = 0; idomain_name < sizeof(str_domain_name); idomain_name++)
                    {
                        if (re_component_domain_name str_domain_name[idomain_name])
                        {
                            print str_domain_name[idomain_name] ":" str_domain_name[idomain_name][match 1] "\n"
                            nstats[2] = str_domain_name[idomain_name][match 1]
                        }
                        else
                        {
                            print str_domain_name[idomain_name] ":" "No match!!" "\n"
                            //nstats[2] = domain
                        }
                    }
                }

     

    Any help would be great

    Not sure exactly what is going on here, but if you declare at the top:

    • string nstats[sizeof(str_domain_name)]

    Then inside your loop you would use "idomain_name" instead of "2":

    • nstats[idomain_name] = str_domain_name[idomain_name][match 1]

    Exporting to Excel is a different matter.

    -Louie

  • KBSri
    KBSri
    104 Posts

    Re: I need to extract only the part of the module name if the folder name is "Sample"

    ‏2014-02-24T10:09:23Z  
    • llandale
    • ‏2014-02-21T17:25:47Z

    Not sure exactly what is going on here, but if you declare at the top:

    • string nstats[sizeof(str_domain_name)]

    Then inside your loop you would use "idomain_name" instead of "2":

    • nstats[idomain_name] = str_domain_name[idomain_name][match 1]

    Exporting to Excel is a different matter.

    -Louie

    Nope Louie. I tried your suggestion too please suggest the alternative.

    The problem is nstats[2] is already hardcoded.The value for the nstats[2] should contain the domain value.But the domain value here in this case is holding the latest of matched string i.e

    nstats[2] = str_domain_name[idomain_name][match 1 is not holding the value consecutively.It is able to hold only the last index value.In this case domain is printing only "MP" as a matched one.

    I have attached the some part of the function code which needs to be evaluated later. Please suggest me the alternative in this case.

    I am badly in need of help in this case.