Split a single string by several seperator

Hi,
I have a string from where i want to get the values for my parameters by splitting the string by the seperator -i, -u, -p.
string:
-ic:\reports\inc\ -ucuriosity -psecret
I want to have those values to be assigned to the variables for further use, like:
$i = c:\reports\inc\
$u = curiosity
$p = secret
the split MUST has to be done using the delimiter -i, -u, -p

Those are regular expressions.  In english, that would translate to "Immediately following either the beginning of the string or a whitespace character, the characters -u followed by one or more non-whitespace characters."
Breaking it down a bit further:
(?<=EXPRESSION):  A zero-width positive lookbehind assertion (I know, it's a mouthful).  Basically, it says that whatever follows must come at a position where the EXPRESSION was matched (but the EXPRESSION itself is not part of the match.)
Now that I look at what I wrote, that wasn't strictly necessary in this case.  This expression would have worked fine:  '(?:\s|^)-u(\S+)', or even just '(\s|^)-u(\S+)', except in the second case, you'd need to retrieve the value of $matches[2]
instead of $matches[1].  More on that later.
\s|^ :  A compound regular expression that can match either a single whitespace character (\s), or the position at the beginning of the string (^).  This was to ensure that we didn't match the characters "-u" if they happened to occur in the middle
of a word somewhere.  The | character is regex's version of the "-or" operator.
-u:  Matches the literal characters "-u"; no special meaning in regex at this point.
(\S+):  Matches one or more non-whitespace characters, and saves them in a capturing group.  \S matches any non-whitespace character, and the + symbol is a quantifier that means "one or more".  The parentheses around that part of the expression
form a capturing group.  In this case, the group is not named, so they're added to the $matches table by number, in order from left to right.
$matches[0] always contains the entire match.  $matches[1] will be the value from the first capturing group, and so on.

Similar Messages

  • Best way to split a single string containing 2 words into word1 and word2

    Whats the best way to take a string containing 2 words and split it into 2 strings ?
    eg. "red ferrari"
    string1 "red"
    string2 "ferrari"

    If your list is always going to have exactly two words, then yes.  Otherwise it depends on your requierments.

  • Convert an array of strings into a single string

    Hi
    I am having trouble trying to figure out how to convert an array of strings into a single string.
    I am taking serial data via serial read in a loop to improve data transfer.  This means I am taking the data in chunks and these chunks are being dumped into an array.  However I want to combine all elements in the array into a single string (should be easy but I can't seem to make it work).
    In addition to this I would also like to then split the string by the comma separator so if any advice could be given on this it would be much appreciated.
    Many Thanks
    Ashley.

    Well, you don't even need to create the intermediary string array, right? This does exactly the same as CCs attachment:
    Back to your serial code:
    Why don't you built the array at the loop boundary? Same result.
    You could even built the string directly as shown here.
    Message Edited by altenbach on 12-20-2005 09:39 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    autoindexing.png ‏5 KB
    concatenate.png ‏5 KB
    StringToU32Array.png ‏3 KB

  • Multiple strings input to single string output

    Dear all,
    this program is needed for my demo simulation purposes, I'm creating several string inputs to show into a single string output updating (input strings are shown in each line). i attached the picture below, put 2 output strings w/c both doesn't meet my desired result:
    1.) 1st string output - replace the old string w/ new string. what i need is to maintain also the previous strings. the new string will go to the next line.
    2.) 2nd string output - although i got all the strings i needed, it only appears right after the while loop terminates, so i did not see the string inputs updating.
    i'm using LV 8.5.1., any help is appreciated... posting your correct code will be more appreciated.
    thanks in advance...
    Ivel R. | CLAD
    Solved!
    Go to Solution.

    here's my code for anyone to see the actual difference.
    thanks,
    Ivel R. | CLAD
    Attachments:
    update strings.vi ‏14 KB

  • Is there a way in Oracle to return multiple rows as a single string?

    Hi gurus,
    I just got help from your guys fixing my dynamic sql problem. What I am doing in that function is to return a single string from multiple rows and I use it in the select statement. It works fine once the problem was solved. But is there any way in Oracle to do this in the select statement only? I have a table that stores incidents (incident_id is the PK) and another table that stores the people that are involved in an incident.
    Incident_table
    (incident_id number PK);
    Incident_people_table
    (incident_id number PK/FK,
    person_id number PK);
    Now in a report, I need to return the multiple rows of the Incident_People_table as a single string separated by a comma, for example, 'Ben, John, Mark'. I asked the SQL Server DBA about this and he told me he can do that in SQL Server by using a variable in the sql statement and SQL Server will auomatically iterate the rows and concatenate the result (I have not seen his actual work). Is there a similar way in Oracle? I have seen some examples here for some similar requests using the sys_connect_by_path, but I wonder if it is feasible in a report sql that is already rather complex. Or should I just stick to my simpler funcion?
    Thanks.
    Ben

    Hi,
    May be, this example will help you.
    SQL> CREATE TABLE Incident_Table(
      2    incident_id number
      3  );
    Table created.
    SQL> CREATE TABLE Person_Table(
      2    person_id number,
      3    person_name VARCHAR2(200)
      4  );
    Table created.
    SQL> CREATE TABLE Incident_People_Table(
      2    incident_id number,
      3    person_id number
      4  );
    Table created.
    SQL> SELECT * FROM Incident_Table;
    INCIDENT_ID
              1
              2
    SQL> SELECT * FROM Person_Table;
    PERSON_ID PERSON_NAME
             1 John
             2 Mark
             3 Ben
             4 Sam
    SQL> SELECT * FROM Incident_People_Table;
    INCIDENT_ID  PERSON_ID
              1          1
              1          2
              1          3
              2          1
              2          2
              2          4
    6 rows selected.
    SQL> SELECT IT.*,
      2    (
      3      WITH People_Order AS (
      4        SELECT IPT.incident_id, person_id, PT.person_name,
      5          ROW_NUMBER() OVER (PARTITION BY IPT.incident_id ORDER BY PT.person_name) AS Order_Num,
      6          COUNT(*) OVER (PARTITION BY IPT.incident_id) AS incident_people_cnt
      7        FROM Incident_People_Table IPT
      8          JOIN Person_Table PT USING(person_id)
      9      )
    10      SELECT SUBSTR(SYS_CONNECT_BY_PATH(PO.person_name, ', '), 3) AS incident_people_list
    11      FROM (SELECT * FROM People_Order PO WHERE PO.incident_id = IT.incident_id) PO
    12      WHERE PO.incident_people_cnt = LEVEL
    13      START WITH PO.Order_Num = 1
    14      CONNECT BY PRIOR PO.Order_Num = PO.Order_Num - 1
    15    ) AS incident_people_list
    16  FROM Incident_Table IT
    17  ;
    INCIDENT_ID INCIDENT_PEOPLE_LIST
              1 Ben, John, Mark
              2 John, Mark, SamRegards,
    Dima

  • StringTokenizer vs. split and empty strings -- some clarification please?

    Hi everybody,
    I posted a question that was sort of similar to this once, asking if it was best to convert any StringTokenizers to calls to split when parsing strings, but this one is a little different. I rarely use split, because if there are consecutive delimiters, it gives empty strings in the array it returns, which I don't want. On the other hand, I know StringTokenizer is slower, but it doesn't give empty strings with consecutive delimiters. I would use split much more often if there was a way to use it and not have to check every array element to make sure it isn't the empty string. I think I may have misunderstood the javadoc to some extent--could anyone explain to me why split causes empty strings and StringTokenizer doesn't?
    Thanks,
    Jezzica85

    Because they are different?
    Tokenizers are designed to return tokens, whereas split is simply splitting the String up into bits. They have different purposes
    and uses to be honest. I believe the results of previous discussions of this have indicated that Tokenizers are slightly (very
    slightly and not really meaningfully) faster and tokenizers do have the option of return delimiters as well which can be useful
    and is a functionality not present in just a straight split.
    However. split and regex in general are newer additions to the Java platform and they do have some advantages. The most
    obvious being that you cannot use a tokenizer to split up values where the delimiter is multiple characters and you can with
    split.
    So in general the advice given to you was good, because split gives you more flexibility down the road. If you don't want
    the empty strings then yes just read them and throw them away.
    Edited by: cotton.m on Mar 6, 2008 7:34 AM
    goddamned stupid forum formatting

  • Splitting a concatenated string to multiple cells in a row in BIP Reports

    Hello Experts,
    Let me how to split a concatenated string into multiple cells in BIP reports rtf.
    Ex:
    string: acg;ghdf;tesrlkjj;hvfffda
    has to placed in multiple cells like
    string1: acg
    string2: ghdf
    string3: tesrlkjj
    string4: hvfffda
    Appreciate your quick reply.
    Please drop in the pseudo code.
    Thanks & Regards
    Syed

    The report is based on a standard sql query such as
    select item1, item2, item3, item4, item5, item6, item7
    from mytable
    order by item1Wanted to put that in as I am not using an interactive report.
    Thanks
    Wally

  • How to specify ");" as a regular expression in split method of String class

    How to specify ");" as a regular expression in split method of String class using delimeters?

    Sorry, you can't specify that by using delimiters. Mostly because this requirement makes no sense.
    Do you rather need "\\);"?

  • Concate mutiple input in to Single String.

    Hi ,
    I need one help .
    I want to contcat  the one of the IDOC  fields occurance in a single string.  Please let me know how to user.
    For Ex.   I am mapping   one field  of Idoc ex TDLINE --> Extrinsic (0.. Unbounded)in the output side.
    In the Input side the TDLINE  fields appears multiple time. in the current mapping I have one to one mapping  between TDLINE and Extrinsic fields.  So it creates the same number of Extrinsic fields as I have TDLINE fields at input side. 
    What I want to  do , I want  to create a single Extrinisc  fields at output side for all the TDLINE fields.
    For Ex.  At particaular segment  I have  10  fields for TDLine then all  should come  as Single string at out put side. 
    Note .  No of Occurance of TD line is 0.. unbounded).
    Please  give ur suggestions for the same.

    Hi Ram,
    i got same problem recently. For this problem there is no standard functions in XI so you must create udf. I wrote that udf and sending with these:
    http://allyoucanupload.webshots.com/v/2003800853095440083
    http://allyoucanupload.webshots.com/v/2003854577844519372
    http://allyoucanupload.webshots.com/v/2003865357113273227
    http://allyoucanupload.webshots.com/v/2003828767547920796
    Regards,
    Sai

  • Parsing a single string

    I apologize if the question is trivial, but I have been working on it for a while.
    I would like to send a single string containing one XML element to the parser. I can't figure out a way to do it.
    Of course, I can easily parse files, but for communication purposes, I need a way to parse just single elements, that are stored in separate strings, and find out their contents.
    Thank you,
    Sol

    Can't your parser accept a Reader as input? Check its API documentation to find that out. If it can, then "whatever.parse(new StringReader(yourXmlString))" is what you want.

  • Convert the IDOC XML file into single string?

    Hello All,
    I have a scenario, where i need to conver the IDOC XML  into single string, to send it to target.
    Please let me know how can we achive this, I dont know java coding.
    Please help me out to write the java code.
    Thanks and Regards,
    Chinna

    Hi Chinna,
    You can do this in two ways -
    1. Java mapping
    https://wiki.sdn.sap.com/wiki/display/XI/JavaMapping-ConverttheInputxmlto+String
    https://wiki.sdn.sap.com/wiki/display/Snippets/JavaMapping-ConverttheInputxmltoString
    2. XSLT mapping
    /people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping
    Regards,
    Sunil Chandra

  • Single string tag expanded into 100 plc register values

    I found a way to read 100 registers of plc data with a single string tag, if you can guarantee that none of the plc registers are zero. A register value of zero acts like a Null ascii terminator and truncates the string. Define the string tag as 200 bytes and uncheck the text data only box. Use the code in the attached picture to convert the string bytes back into decimal register values.
    Attachments:
    string tag to 100 U16 values.gif ‏2 KB

    Ins't that code exactly the same as typecasting to an U16 Array?
    Message Edited by altenbach on 05-19-2005 07:24 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    CastingU16.gif ‏3 KB

  • Pages (5.2.2): Split a single Table Cell

    Hi everyone,
    Is there anyway to split a single Cell in an existing Table?
    Thanks for your help,
    Prusten,

    …and you win!
    Peter

  • How convert a big image to parts of images? means split a jpg image to several sub imges.(thi​s sub image can joint into that big image)

    hi friends..
    how convert a big image to parts of images? means split a jpg image to several sub imges.(this sub images can joint into that big image) any help
    Solved!
    Go to Solution.

    In the example, i have created two images and added them together, and the converse can be done in the same way.
    Thanks
    uday,
    Please Mark the solution as accepted if your problem is solved and help author by clicking on kudoes
    Certified LabVIEW Associate Developer (CLAD) Using LV13

  • Split Comma Delimited String Oracle

    I want to Split Comma Delimited string in oracle9i into rowwise data.i do not want to use Functions or connect by level...
    is there any other way from which we can split strings.???
    if we use Connect by level method the problem im facing is we cannot use suqueries in Connect by clause...
    Edited by: user11908943 on Sep 16, 2009 8:37 AM

    michaels2 wrote:
    I prefer using XMLTABLE which has superceded XMLSEQUENCE and I personally find it easier to read...Agree, but that would be hard in 9i since it is not implemented ;)Ah! missed that bit (gawd I wish people would upgrade to supported versions)
    In still later versions (11g) I prefer
    SQL>  with t as
    select 'a,b,c,d,e' str from dual
    select trim(column_value) str
    from t, xmltable(('"' || replace(str, ',', '","') || '"'))
    STR                                                                            
    a                                                                              
    b                                                                              
    c                                                                              
    d                                                                              
    e                                                                              
    5 rows selected.
    Natty! But completely illogical (I mean creating an XMLTABLE from a non-XML string). I'm guessing that's a development of XQuery?

Maybe you are looking for

  • Is there a central note available yet for Upgrading to NW 7 EHP 5?

    Hi all, I'm trying to find out if there is a central note available for upgrading to NW 7 EHP5. I have note 1299009 which is the central note for upgrading to NW 7 EHP 2 but I'm trying to find one for EHP 5 specifically (if it exists at all). The rea

  • Not a valid photoshop document

    Had 2 files on screen, I quit photoshop and when asked to save I did, the files took a long time to save, but they did save succesfully. Trying to open the file today and I get this now: The file size looks to be of proper size at 37.8mb, and is on W

  • Ipod nano 3rd Gen not recognized by itunes or windows 7

    USB device not recognized.   things I have done put Ipod in disk mode still didn't recognized My Ipod Classic 6th Gen works fine It shows 3 Mass Storage Device when I plug in Ipod nano 3rd gen it shows unknow device have deleted Mass storage devices

  • Default settings for File Chooser dialog

    I reach the file chooser dialog by selecting File-Open File. Under the toolbar-options menu in the Open File Dialog, I can select to have a bookmark icon appear on the toolbar. How do I set a default to have the Bookmark icon always appear? Firefox 1

  • Export Query to Excel Issue

    I have created this query and placed it in query manager: SELECT T0.[CheckKey] as [Internal ID],T0.[CheckNum] as [Check No.],T0.[AcctNum] as [Acct No.],cast(t0.[checksum] as INTEGER),T0.[PmntDate] as [Issue Date] FROM OCHO T0 WHERE T0.[PmntDate] =[%0