10 Replies Latest reply: Nov 18, 2013 9:45 AM by Srikanth P RSS

    String Function

    anitha lux

      Is there a string function to convert my string of type servername.na.corp.companyname to servername.

      I have to delete the .na.corp.companyname part.

        • Re: String Function
          Jeremiah Kurpat

          =Subfield('servername.na.corp.companyname', '.',1)

           

          Hope this helps!

            • Re: String Function
              anitha lux

              Thanks a lot for your quick response... It worked really well expect for some servernames are in numeric form and I want them not to change For Example : 10.32.123.45 ... So by using the previous function it is returning me just 10 but that is not intended !!... How do I go around this??

            • Re: String Function

              Hi,

               

              I think subfield can do that job (but there will be other ways as well).

               

              subfield(s, 'delimiter' [ , index ] )

              In its three-parameter version, this script function returns a given substring from a larger string s with delimiter

              'delimiter'. index is an optional integer denoting which of the substrings should be returned. If index is

              omitted when subfield is used in a field expression in a load statement, the subfield function will cause the

              load statement to automatically generate one full record of input data for each substring that can be found in

              s.

              In its two-parameter version, the subfield function generates one record for each substring that can be taken

              from a larger string s with the delimiter 'delimiter'. If several subfield functions are used in the same load

              statement, the Cartesian product of all combinations will be generated.

              Examples:

              subfield(S, ';' ,2) returns 'cde' if S is 'abc;cde;efg'

               

              Regards,

               

              Gerrit

                • Re: String Function
                  anitha lux

                  Thanks a lot for your quick response... It worked really well expect for some servernames are in numeric form and I want them not to change For Example : 10.32.123.45 ... So by using the previous function it is returning me just 10 but that is not intended !!... How do I go around this??

                • Re: String Function
                  diego GOmez

                  Subfield('servername.na.corp.companyname', '.',1)

                  &'.'&

                  Subfield('servername.na.corp.companyname', '.',2)

                  &'.'&

                  Subfield('servername.na.corp.companyname', '.',3)

                  &'.'&

                  Subfield('servername.na.corp.companyname', '.',4) as ServerName

                  • Re: String Function
                    Clever Anjos

                    na.corp.companyname is always fixed?

                    If yes

                    =left('10.32.123.45.na.corp.companyname',index('10.32.123.45.na.corp.companyname','.na.corp.companyname')-1)