Best way to parse a delimited string

Hello-

I am trying to understand better, more concise way to parse this string:
'FNAME=JANE|L_NAME=DOE|ACTIVE_PLAN_CODE=Y0|BEN_MOD_ID=4695'
I played a bit with using Substr and Instr, but the code seems to have a little messy, so I thought I would check to see if there was an easier way.

Are the values that I need to analyze
Jane, Doe, YO, 4695.
Thank you!
Christine

Maybe like this

SQL> with dat as (
    Select 'FNAME=JANE|L_NAME=DOE|ACTIVE_PLAN_CODE=Y0|BEN_MOD_ID=4695' col from dual
    )
    select
            InitCap(regexp_substr(col,'[^=|]+',1,2))||',' col1
    ,       InitCap(regexp_substr(col,'[^=|]+',1,4))||',' col2
    ,       regexp_substr(col,'[^=|]+',1,6)||',' col3
    ,       regexp_substr(col,'[^=|]+',1,8)||'.' col4
    from       dat
/

COL1  COL2 COL COL4
----- ---- --- -----
Jane, Doe, Y0, 4695.

SS

Tags: Database

Similar Questions

  • Best way to cast to a string

    Hello

    I want to convert item.someNumber to a string to count this char in length. If it has a single tank, I prepend a '0', otherwise I don't touch it.

    What is the best way to do it?

    item.someNumber.toString)

    String (Item.someNumber)

    (String) item.someNumber

    ?

    Thank you.

    If (someNumber<>

    {

    someString = '0' + someNumber;

    } else {}

    someString = String (someNumber);

    }

    or a Variant if you handle negative numbers

    If (someNumber < 10="" &&="" somenumber=""> 0)

  • Best way to parse a string for use in a lookup table?

    I am trying to create a system by which users can create a premade simulation and store simulations in order to easily load at their convenience. The way it works now is that when the user creates a simulation, information on the characteristics of the simulation are condensed down to a 12 string, which is written in a text file with the same name as its content. This string is then read, and ideally, I would have some sort of lookup table to convert characters in the information they have been condensed to. For example, a variable X can have possible values {650,720,851} who gets the mapping to {A, B, C} during the creation process. When loading, I would be able to send in a Sub C - VI and took her out in 851, group in a cluster. How can I perfectly realize this in LV? So far the best I have is this messy thing:

    Basically, who runs the string character by character and includes the appropriate value for the character at the given offset.

    You want to use the configuration VI palette.

    These screws makes it stupid simple save and load the values in the file by using Sections and keys.

    You can use the keys 'A', 'B' or 'C' and section 'X' to complete your example.

  • Best way to Parse XML using Dreamweaver CC 2015.3

    I was on a wild goose chase - trying to figure out how to parse XML using DW CC

    every article I read, says something about XML & XSLT, but it is no longer available in the new CC - I read about using jQuery or php, but have not yet find a resource to learn specifically "using DW CC.

    I'm willing to learn how to parse XML with DW CC but I would get a definitive direction to go before I'm trying to learn something that adobe will put in 'end of life '.

    advice or links to resources that can parse XML DW CC 2015 would be LARGELY APPRECIATED, thank you

    x 126 has written:

    What I'm asking is...

    1. What is the best procedure to insert XML into a page using DW CC 2015 as my editor?
    a. what happened to spry? b. what happened to XSLT?

    As Nancy explained, Spry has been abandoned by Adobe, a few years ago.

    XSLT server behavior has been removed at the same time as other server behaviors Dreamweaver CC. The problem with most of the PHP server behaviors was that they were based on code that has been removed from PHP 7. The XSLT server behavior didn't rely on these features, but it was not the most friendly of server behaviors. XSLT is a complex language that is to be avoided when parsing XML unless you really know what you're doing.

    The easiest way to manipulate XML in Dreamweaver should use PHP SimpleXML. I've linked to the samples page in the PHP online documentation. Believe me, it's much easier than trying to do battle with XSLT. If you have a subscription to lynda.com, you can learn more about SimpleXML to my operational with SimpleXMLclass.

  • best way to parse XML without a XSD

    Hello

    In the past whenever I've had to deal with XML, I had an XSD that I could use to marshal the XML in a bean. But now I have to communicate to an API that returns XML that have no any XSD or other type of document description XML.

    I was going to just to use string mute and corresponding analysis. Is there a better way to deal with this? Is there like a tool or library that will be the input XML ICD and put it in a container that is widespread with cards and such that I can pull the data I want?

    Thank you
    Jose

    >
    In the past whenever I've had to deal with XML, I had an XSD that I could use to marshal the XML in a bean. But now I have to communicate to an API that returns XML that have no any XSD or other type of document description XML.

    I was going to just to use string mute and corresponding analysis. Is there a better way to deal with this? Is there like a tool or library that will be the input XML ICD and put it in a container that is widespread with cards and such that I can pull the data I want?
    >
    So what stops you to create your own XSD?

    The basic structure you need to analyze and process the data anyway. So why not simply capture the structure you need in an XSD, and then use this XSD the same way you have always (e.g. XMLBeans or other).

    If you are looking for on the net you can find some freeware libraries that can create a basic XSD from an XML doc. More complete example XML is the best work they can do. Use one of those to get the first draft of a XSD and then to embellish it.

    You can also use Apache Commons Digester to only have access to the raw XML data.
    http://Commons.Apache.org/proper/Commons-digester/

  • Best way to transfer strings, arrays and clusters

    Hi, I just want to know the best way to transfer strings, arrays and clusters between a PC and a computer-RT (compactRIO) if I want to use them in deterministic loops:

    For a string should I use a published network shared variable flow or network?

    For an array of doubles should I flatten the array in a string and the string of transfer? or should I send it as a picture?

    The same for clusters, should I flatten the cluster or the transfer as a cluster?

    Thank you!

    Transfers on the network are not deterministic.  You ask how to use the data in a deterministic way, once it arrives on the RT system.  Usually, you would create a separate loop, not critics of time to deal with network communications.  The data arrives it is copied in real-time-safe structures such as RT-FIFO to put at the disposal of the evanescent loop.

    I can't give you specific advice on network variables and network flows; Finally, I did this kind of transfer over TCP, until these other options were available.

  • Best way to remove the apostrophe from the string when loadiing

    Salvation by using an insert statement to load the data some string apostrophe.

    Please make sure that all aposrophe of removed from these channels on loading.

    What is the best way to reach EThis.

    Uisng 11.2.0.3


    Thank you

    One way:

    with data as
    (
      select 'some '' data' col from dual
    )
    select col, replace(col, '''', '') rep
      from data;
    
    COL         REP
    ----------- -----------
    some ' data some  data 
    
  • best way to find out: string in number and &gt; 0

    What is the best way to determine whether the input string (which is surely not null) is a whole number greater than zero and positive without a comma.
    The correct values are: 1, 2,...,

    To determine if the string is a whole number, I can do this way:

    Select decode (REGEXP_INSTR ('1 ',' [^ [: digit:]]'), 0, 'NUMBER', 'NOT_NUMBER') of double;

    But I do not know how to change the regular expression so that it would fail to zero to be the first tank.

    Or is there a better way?
    SQL> with t as (select '-1' s from dual
               union all
               select '0' from dual
               union all
               select '109' from dual
               union all
               select '0109' from dual
               union all
               select '1.5' from dual)
    select t.s, case when regexp_like (s, '^[1-9]+[0-9]*$') then 'NUMBER' else 'NOT A NUMBER' end test
    from t
    /
    S    TEST
    ---- ------------
    -1   NOT A NUMBER
    0    NOT A NUMBER
    109  NUMBER
    0109 NOT A NUMBER
    1.5  NOT A NUMBER
    
    5 rows selected.
    
  • What is the best way to obtain a string that represents a date in the format mm/dd/yyyy

    What is the best way to obtain a string that represents a date in the format mm/dd/yyyy

    It would be good if I could generate this string using the static methods of a class.






    You can use date formatter:

    Import mx.formatters.DateFormatter;
    ...

    var trainer: DateFormatter = new DateFormatter();
    formatter.formatString = "YYYY/MM/DD JJ:NN:SS;
    var today: Date = new Date();
    trace (formatter.format (now));

  • Large enough string - what is the best way to apply

    Hi guys,.

    I have user agreement which is about 1300 characters, could someone please tell me the best way to store and retrieve? and also view it.

    I don't want to cramp, the memory of the blackberry. I build on the JDE version 4.5.

    Thanks in advance.

    the solution that I opted for a similar problem had to include the agreement, entirely in the format, in html format in the project.

    I use the browser to view it then.

  • Best way to code structure to control several instruments

    Hello

    I am a novice but not inexperienced labview programmer. I'm writing a labview code to control a physical optical experiement. This involves writing a GUI which of your interfaces then with a variety of instruments (such as motorized turntables, lock-in amplifiers, power supplies, Renault, etc...) all connected to the computer through various means. All the instruments are delivered with their own labview drivers to complete their most important functions. Essentially, the instruments will operate independently, but occasionally, will be a set of steps involving several instruments (such as move, take a step, move again,...)

    My question is what is the best way to structure the top level VI where all GUI controls? I have currently the code structured so that each instrument has an event structure that manages keys and commands for it. Simple events like the movement are dealt with in the cases where structures themselves while queues and occurrences are then used to handle more complicated events in external loops. It is an appropriate way to handle this scenario, or is it that most commonly architecture?

    Thank you for the help

    You play with fire when using several structures of the event. My preferred method for executing an instrument that has a 'stream' mode (example: a spectrometer where you always see the spectrum), is to provide that it is a clean line, with a dequeue item. The 'element' may have a message part (or State) in the form of an enum or string, as well as some data in the form of a Variant. You want to set a parameter, you could send a cluster containing the enum "Set the parameter" as well as the value of the parameter in the form of a Variant. The default case would be to get a spectrum and update a graph (or send another message to a user interface management loop that updates the chart).

    You can open the project template QMH who comes with LabVIEW to see how a line would work, and then you can add multiple queues for different instruments. I keep the new loops in their own SubVIs and reference to the queue in a global functional to clean the main schema.

    Here is an example of what your data of the module flow record might look like (the string constant empty considered double quotes is by default to expire the message dequeue)

  • check registartion early? best way to implement

    Hey guys,.

    I tried to determine the best way to make my request to verify a valid registration on startup key and if the key is valid, the tracks of the app.  If the key is not there, or invalid, it has a pop up screen to enter a registration code.   Any help would be appreciated in pointing me in the right direction.

    (I have already created screen pop-up)

    You do this verification early in the process. Try something like this:

    public class MyApp extends UiApplication {
    
      public static void main(String[] args) {
        final MyApp app = new MyApp();
        app.invokeLater(new Runnable() {
          public void run() {
            app.doStartupWork();
          }
        }
        app.enterEventDispatcher();
      }
    
      void doStartupWork() {
        if (!registered()) {
          PopUp popUp = new PopUp();      pushModalScreen(popUp);      if (popUp.registrationFailed()) {        System.exit(0);      }    }
        pushScreen(new AppMainScreen());  }
    
      boolean registered() {
        // check for existing registration key
      }
    }
    
  • Best way to send data

    Hello

    It is more a question aside server, but I wanted to see what is the 'best practice' BB, and how the experts deal with this scenario.

    I intend to use servlets to serve data over HTTP to my BB application.  I need to retrieve a list of images more associated with name, description, dates, etc.  Sent a picture of servlet, I know that I can just send it as a byte array and the BB it can read the http input stream.  What to send the image and data? How can we separate the bytes of the image of the data bytes. Can I send a collection of images and associated data?

    What is the best way to address the issue?

    Thank you

    T

    I would answer the question by asking "what your infrastructure server-side looks like?

    If it's dot net, then you will probably want to take the path of least resistance and use JSR 172 or KSOAP.

    If you have more flexibility on the server, I recommend XML or JSON (as Peter says). JSON is going to be more compact, but the BB JSON tools are a bit sparse.

    On the other hand, SAX on the BB parser libraries are good enough for XML.

    I would say that in every project I've ever worked, I bypassed the weaknesses of the infrastructure server, rather than the reverse.

  • What is the best way for foglight consume a webservice

    I hope that this is has not been replied that a bazillion times and if it is please send me the link I'm open to that.  What is the best way for foglight consume a Web service and respond with an alarm if the response from the Web service is not what is expexted.

    for example, calls Foglight webservice to acme.com/areuup and he responds with correct status in json format process.  If it does agree return, then foglight must send alerts to correct individuals.

    Thank you

    Kaleb

    in the end, we have used a perl script to capture the webservice and treat it and tables configuration.  Here is what has been written and created an agent custom.

    I apologize to all those who find the bulky comments, but it's my edition of journal of the script. I removed the comments once the script has been published and used.

    ===

    #! / usr/bin/perl

    #############################################################

    # Author: Kaleb J. Albee

    # Depandancies: SOA webservice

    # Engineers: Marc and Manu

    # Date: 28/02/2013 perl: (v5.14.2) built for x86_64-linux-gnu-thread-multi

    # Operating system: Linux 3.2.0 - 29-generic eam-ops-test #46 - Ubuntu SMP Wed Jul 27 17:03:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    #############################################################

    use strict;

    use warnings;

    use Try::Tiny;

    use SOAP::Lite;

    use SOAP::WSDL;

    Use Time::Local;

    My = @soaenvs ('BSE - dev', 'BSE test', 'BSE-scene', 'BSE');

    # parameters: $_ [0] receives a call of SOAP client object.

    #

    void toStr {return $_ [0] == 1?} 'up': 'down' ;}

    void getBusResults {}

    # $_ [0] will be the $client spent

    # create a different buses SOAP connection.

    my $result = $_ [0]-> (getMessagingEngineHealth)

    # arg0 is used to set the setting for what is expected on the soa web service.

    SOAP::Data-> name (arg0 => $_ [1]));

    # $_ [1] will be the bus happened in

    return (Lk ($result) "started" eq? 1: 0);

    #return $result;

    }

    # Start sampling.

    My $curTimeStamp = "";

    my $count = 0;

    Print "LdsEsbBusHealth5\nSTART_SAMPLE_PERIOD\n TABLE";

    foreach my {$soae (@soaenvs)

    my $client is SOAP::Lite-> service ("put the url of the webservice here.");.

    $count ++;

    # create an object to inspect objects. My $insp = Data new::Inspect->; Download the time stamp for this.

    my ($sec, $min, $hr, $day, $mon, $year) = localtime;

    # format the year correctly for useage.

    My $curyear = 1900 + $year;

    # the hand to the fglam agent fields at the tables.

    My $soacei = getBusResults ($client, "messaging.000 - CEI.esb.BUS");

    My $soaapp = getBusResults ($client, "messaging.000 - SCA.APPLICATION.esb.Bus");

    My $soasys = getBusResults ($client, "messaging.000 - SCA.SYSTEM.esb.Bus");

    $curTimeStamp = ' $curyear$ MON$ day$ hr$ min$ s ";

    Print "SoaEnv.String.id=$soae\n";

    Print "CeiBusNum = $soacei\n";

    Print "AppBusNum = $soaapp\n";

    Print "SysBusNum = $soasys\n";

    Print "CeiBusStr.StringObservation.obs =". toStr ($soacei). "\n";

    Print "AppBusStr.StringObservation.obs =". toStr ($soaapp). "\n";

    Print "SysBusStr.StringObservation.obs =". toStr ($soasys). "\n";

    Print "Daterun.StringObservation.obs=$curTimeStamp\n";

    If ($count<=>

    Print ("NEXT_SAMPLE\n");

    }

    } {$soae foreach (@soaenvs) #.

    Print "END_TABLE\n";

    Exit 0;

    ===

    I hope this helps someone out there!

    Bravo!

  • The best way to manage two GUI

    I have two classes using java swings. The first Panel is where all the calculations will be made and the result will appear in a JList (in the 1st Panel). After that, the next button will show a 2nd Panel where the JList of the 1st group results are transferred. I need a back button in the 2nd Panel to return to the Panel 1. After you click the back button, I need the previous results on the 1st Panel to always be there for extra change (add / change / delete data). If I changed something and click the next button again, I want the 2nd Panel show a set results to date from the 1st Panel.

    What is the best way to do it? I spent two days trying to apply this using the presentation of the card, but it does not work as I want. All the examples I found use only one category. Even if I break down for separate classes, I face problem where when I click the back button, all the data in the 1st Panel disappeared. I'm out of my mind right now. It would be great if anyone can share some ideas in this. Any suggestions are welcome.

    Yes. I already tried several times to break it down into categories before posting here again. I am new to Java, that's why I found quite difficult and decided to post my problem here after he tried for two days. In any case, I thought about it already. I share the codes so that anyone who has problems like me can be useful if not much.

    Presentation of the main card:

    import java.awt.CardLayout;
    
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    
    public class CardCard {
      private static final String FIRST_PANEL = "firstPanel";
      public static JPanel mainPanel;
      private JFrame frame;
      public static CardPanel_1 cp1 = null;
      public static final CardLayout cardLayout = new CardLayout();
    
      public CardCard (){
      frame = new JFrame("Test");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationByPlatform(true);
      mainPanel = new JPanel(cardLayout);
      cp1 = new CardPanel_1();
      mainPanel.add(cp1, FIRST_PANEL);
      frame.getContentPane().add(mainPanel);
      frame.pack();
      frame.setVisible(true);
      }
    
      public static void main(String... args) {
      SwingUtilities.invokeLater(new Runnable()
      {
      public void run()
      {
      new CardCard();
      }
      });
      }
    
    }
    

    First card:

    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.Observable;
    import java.util.Random;
    
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    public class CardPanel_1 extends JPanel {
      public static JTextField textField, textField3;
      private static final String SECOND_PANEL = "secondPanel";
      private CardPanel_2 observer;
      private JButton btnNext, btnRandom;
      private String show;
      public CardPanel_2 cp2 = null;
      private List numList;
      private String numResult;
    
      /**
      * Create the panel.
      */
      public CardPanel_1() {
      setLayout(new FlowLayout());
    
      textField = new JTextField();
      textField.setBounds(64, 5, 134, 28);
      add(textField);
      textField.setColumns(10);
    
      textField3 = new JTextField();
      textField3.setBounds(64, 5, 134, 28);
      add(textField3);
      textField3.setColumns(10);
    
      btnRandom = new JButton("Randomise");
      btnRandom.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      String str = textField.getText();
      int num = Integer.parseInt(str);
      numList = new ArrayList();
      for (int i =0;i
    

    2nd map:

    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Observable;
    import java.util.Observer;
    
    import javax.swing.JButton;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    
    public class CardPanel_2 extends JPanel implements Observer {
     private static JTextField textField2;
      private JButton btnBack;
     private static final String FIRST_PANEL = "firstPanel";
    
     /**
      * Create the panel.
      */
      public CardPanel_2() {
      System.out.println("PANEL 2");
      textField2 = new JTextField();
      add(textField2);
      textField2.setColumns(10);
      btnBack = new JButton("Back");
      btnBack.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent evt) {
      CardCard.cardLayout.show(CardCard.mainPanel, FIRST_PANEL);
      System.out.println("BACK");
      }
      });
      add(btnBack);
      }
    
      public void update(Observable o, Object arg) {
      System.out.println("Updated: " + CardCard.cp1.textField3.getText());
      textField2.setText(CardCard.cp1.textField3.getText());
      }
    }
    

Maybe you are looking for