13 Replies Latest reply: Feb 26, 2013 9:33 AM by gimbal2 RSS

    Spliting the string using unique character as a delimeter

    800839
      Hi,

      I have a requirement, where a customer number does have varchar as a datatype in Oracle DB, where in the GUI it accepts
      any special characters , hence it can be like:-

      CUST-001
      CUST,001
      CUST#001
      CUST%001
      CUST@001

      so on....

      Here the above customer numbers are valid ones, hence i cannot remove these special characters from Customer number and
      make it CUST001 which is incorrect and will produce no result.
      In the GUI we are appending CUSTNAME & CUSTNO using "-"(hyphen) as a delimeter. Hence if the CUSTNO is coming with "-" (hyphen)
      then the parsing or spliting the CUSTNAME & CUSTNO is having an impact and hence it is throwing an error in the application.
      Please suggest me which delimeter can be used to split the string (CUSTNAME & CUSTNO) which does not matches with any of
      the special characters that CUSTNO can have? So that it wont cause any problem? Please clarify.

      Thanks.
        • 2. Re: Spliting the string using unique character as a delimeter
          rp0428
          >
          In the GUI we are appending CUSTNAME & CUSTNO using "-"(hyphen) as a delimeter. Hence if the CUSTNO is coming with "-" (hyphen)
          then the parsing or spliting the CUSTNAME & CUSTNO is having an impact and hence it is throwing an error in the application.
          Please suggest me which delimeter can be used to split the string (CUSTNAME & CUSTNO) which does not matches with any of
          the special characters that CUSTNO can have? So that it wont cause any problem? Please clarify.
          >
          You are the one that needs to clarify - clarify what your requirement is and provide an example of the data you are talking about.

          If you are 'appending CUSTNAME & CUSTNO using "-"(hyphen) as a delimeter' then you have to split that at the hyphen.

          Why are you 'appending' those two in the GUI to begin with? And why do you need to split it later? You said it was already split until YOU appended it together.

          There is something you aren't telling us to start over and explain it again.
          • 3. Re: Spliting the string using unique character as a delimeter
            800839
            Thanks Rp, I hope that I am clear with my question.

            For example I am getting the CUSTNO & CUSTNAME appended using a delimeter "-" like BOB-CUST001. There is a possibility that CUSTNAME can have
            any special characters hence it can have "-" as well. Like CUST-001 in such a case if we use "-" as a generic delimeter it will parse the CUSTNAME like CUST & 001. Which is wrong. Hence I need to use some unique identifier which can be a used as a generic identifier which will parse the CUSTNAME which contains any special character. Which identifier I can use here as a generic delimeter? I hope I am clear with my question?

            Thanks.
            • 4. Re: Spliting the string using unique character as a delimeter
              UdayaShankaraGandhi
              Hi
              You can any use character as a delimeter which wont repeat in your customer name and customer id data retrieving from the database. My suggestion is use *!* as a delimeter (expecting no person name contains it :) ).
              • 5. Re: Spliting the string using unique character as a delimeter
                EJP
                where in the GUI it accepts any special characters
                Why? Why not have the same rules in both places?
                Please suggest me which delimeter can be used to split the string (CUSTNAME & CUSTNO) which does not matches with any of the special characters that CUSTNO can have?
                Why? Why do you want to have two sets of rules?
                • 6. Re: Spliting the string using unique character as a delimeter
                  r035198x
                  Again, why are you getting CUSTNO & CUSTNAME appended using a delimeter "-" ? Who is appending those two together like that?
                  If you are looking for an alternative delimiter then it means you are allowed to change the code right? So change it so that you don't append those two pieces of information at all. Pass the information as separate fields and then later you won't have to split any fields. What is the reason for appending them together when your use requires that they be treated separately later?
                  • 7. Re: Spliting the string using unique character as a delimeter
                    r035198x
                    Udaya Shankara Gandhi wrote:
                    Hi
                    You can any use character as a delimeter which wont repeat in your customer name and customer id data retrieving from the database. My suggestion is use *!* as a delimeter (expecting no person name contains it :) ).
                    In most applications customers can be companies and company names can have special characters including '!' so it's not wise to use it as a delimiter.
                    • 8. Re: Spliting the string using unique character as a delimeter
                      800839
                      Guys I am really sorry I am not getting this? Any examples are highly appreciated.
                      • 9. Re: Spliting the string using unique character as a delimeter
                        r035198x
                        797836 wrote:
                        Guys I am really sorry I am not getting this? Any examples are highly appreciated.
                        Don't append the two together if you want to read them back separately again. Keep them in separate fields and read them back separately.
                        • 10. Re: Spliting the string using unique character as a delimeter
                          800839
                          Thanks.

                          " Keep them in separate fields and read them back separately"

                          At this point of time is really tough as that existing code change will have an huge impact on other dependent functionalities. Hence this is ruled out. Is there any other way to deal with it?
                          • 11. Re: Spliting the string using unique character as a delimeter
                            r035198x
                            797836 wrote:
                            Thanks.

                            " Keep them in separate fields and read them back separately"

                            At this point of time is really tough as that existing code change will have an huge impact on other dependent functionalities. Hence this is ruled out. Is there any other way to deal with it?
                            Are you sure using a different delimiter will not cause just as much impact on the dependent 'functionality'? Not to mention the fact that there will be some data where it will not work. If the code needs to change then better change it with a solution that is fool proof rather than a fragile one.
                            • 12. Re: Spliting the string using unique character as a delimeter
                              rp0428
                              >
                              At this point of time is really tough as that existing code change will have an huge impact on other dependent functionalities. Hence this is ruled out. Is there any other way to deal with it?
                              >
                              No -

                              A ridiculous example should show you why.

                              Assume you have a first name and a last name and each of them can contain any letter from A to Z in upper or lower case. My 'GUI app' concatenates them together using ANY letter from the alphabet from A to Z.

                              Here are some sample names after my GUI has concatenated the first and last names together
                              1. abcdefg
                              2. hijklmnopqr
                              Can you tell me how to tell what the first name is and what the last name is for each of those examples? Of course not.

                              And without some unambiguous rules you can't write code that can do it either.

                              You either have to
                              1. use a unique delimiter (one that can NOT appear in the actual values)

                              or

                              2. you have to use an 'escape' mechanism. Are you familiar with the 'escape' character (the backslash '\') Java uses for strings? They have to use an escape character like that to prevent exactly the sort of problem you are having. Sometimes apps use 'two' of a character to mean one character.

                              So if you want to include a double-quote in a string that uses double-quotes as terminators you use two of them in a row:

                              "This string includes only one "" in the middle of the string"

                              There are NO workarounds.
                              • 13. Re: Spliting the string using unique character as a delimeter
                                gimbal2
                                C F wrote:
                                Use '$@$'
                                I wonder what is wrong with this suggestion. Using a multichar delimiter lowers the chance of a collision to almost zero.