4 Replies Latest reply: Jul 31, 2013 2:18 AM by BluShadow RSS

    Last and Rest Value in a string

    931711

      Guys,

       

      Again i end up with some problem.

       

      I have a string '(ABC/CDE)*XYZ*PQR'

       

      I want to segregate the string as '(ABC/CDE)*XYZ' and 'PQR'

       

      *** Note that the the operators are dynamic. It can be any arithmatic operator.

       

      Please help me in getting it done. Also the string is dynamic.

       

      Thanks & Regards,

      BS.

        • 1. Re: Last and Rest Value in a string
          chris227

          select

              regexp_replace('(ABC/CDE)*XYZ*PQR','[^[:alpha:]][[:alpha:]]+$') first

             ,regexp_substr ('(ABC/CDE)*XYZ*PQR','[^[:alpha:]]([[:alpha:]]+)$', 1, 1, null, 1) last

          from dual

           

          FIRST LAST

          "(ABC/CDE)*XYZ" "PQR"

           

          or with digits

           

          select

              regexp_replace('(123/123)*123*456','[^[:digit:]][[:digit:]]+$') first

             ,regexp_substr ('(123/123)*123*456','[^[:digit:]]([[:digit:]]+)$', 1, 1, null, 1) last

          from dual

           

          FIRST LAST

          "(123/123)*123" "456"

           

          you may take [:alnum:] for alphanumerics

           

          Message was edited by: chris227 extended

          • 2. Re: Last and Rest Value in a string
            BluShadow

            So now what are you trying to do?

             

            I assume this follows on from your wanting to evaluate formulae stored in the database:

             

            Formula Value Creation

             

            Where is all this leading?  It would seem that you need to be writing an arithemetic language parser.  The number of weeks you've already spent doing this would suggest that you're going about something the wrong way if you're still concerning yourself with how to break up the formulae.

            • 3. Re: Last and Rest Value in a string
              931711


              Dear Blu,

               

              I got the formula stuff corrected  .. and i am fine with it ..

              Credit goes to you :-)

              This post is for another problem which i faced.

               

              Thanks & Regards,

              BS

              • 4. Re: Last and Rest Value in a string
                BluShadow

                I was just wandering what the 'bigger picture' is, as this is obviously related.  It may be that you are tackling small parts of a bigger issue and getting several small solutions when you could provide a bigger picture and get a single solution that deals with it all.