Regular Expressions on strings

How would I go about creating a regular expression in LabVIEW that, say, takes an input of a list of numbers (1, 2, 3, 4, 5) and turns it into an array with the elements [1, 2, 3, 4, 5]? If someone could show me example code, I would be quite grateful.
Thanks.
Using LabVIEW 2009 on Windows Vista

Spreadsheet String to Array should work for conversion to strings or numbers...
Richard
Attachments:
stringarr.gif ‏18 KB

Similar Messages

  • Wat should be the regular expression for string MT940_UB_*.txt to be used in SFTP sender channel in PI 7.31 ??

    Hi All,
    What should be the regular expression for string MT940_UB_*.txt and MT940_MB_*.txt to be used as filename inSFTP sender channel in PI 7.31 ??
    If any one has any idea on this please let me know.
    Thanks
    Neha

    Hi All,
    None of the file names suggested is working.
    I have tried using - MT940_MB_*\.txt , MT940_MB_*.*txt , MT940*.txt
    None of them is able to pick this filename - MT940_MB_20142204060823_1.txt
    Currently I am using generic regular expression which picks all .txt files. - ([^\s]+(\.(txt))$)
    Let me know ur suggestion on this.
    Thanks
    Neha Verma

  • Regular Expressions and String

    How do I return a String array as follow using regular expression.
    String[] strArray = {"Now is the time", "you can optionally preview your post","message by using a number of special tokens."}
    from this string
    <separator>Now is the time</separator><separator>you can optionally preview your post</separator><separator>message by using a number of special tokens.</separator>
    Note: The string has the <separator> XML tag

    How do I return a String array as follow using regular
    expression.
    String[] strArray = {"Now is the time", "you can
    optionally preview your post","message by using a
    number of special tokens."}
    from this string
    <separator>Now is the time</separator><separator>you
    can optionally preview your
    post</separator><separator>message by using a number
    of special tokens.</separator>
    Note: The string has the <separator> XML tag
    This cannot be done using simple regular expressions - at least not if your number of <separator>s is random, which is what you seem to imply.
    Simple regular expressions are one-off, that means it can have a String array as a result, but only to the amount of brackets in the regex.
    a regex like:
    <separator>([^<]*)</separator><separator>([^<]*)</separator><separator>([^<]*)</separator>
    would return what you want, but I doubt that it is as flexible as you want it to be.

  • Regular Expressions and String variables

    Hi,
    I am attempting to implement a system for searching text files for regular expression matches (similar to something like TextPad, etc.).
    Looking at the regular expression API, it appears that you can only match using string variables. I just wanted to make sure this is true. Some of these files might be large and I feel uneasy about loading them into ginormous Strings. Is this the only way to do it? Can I make a String as big as I want?
    Thanks,
    -Mike

    Newlines are only a problem if you're reading the
    text line-by-line and applying the regexp to each
    line. It wouldn't catch expressions that span
    lines.
    @sabre150: your note re: CharSequence -- so what
    you're suggesting is to implement a CharSequence that
    wraps the file contents, and then use the regexps on
    the whole thing? I like the idea but it seems like
    it would only be easy to implement if the file uses a
    fixed-width character set. Or am I missing
    something...?You are correct for the most basic implementation. It is very easy to create a char sequence for fixed width character sets using RandomAccessFile. Once you go to character sets such as UTF-8 then more effort is required.
    While ever the regex is moving forward thought the CharSequence one char at a time there is no problem because one can wrap a Reader but once it backtracks then one needs random access and one will need to have a buffer. I have used a ring buffer for this which seems to work OK but of course this will not allow the regex to move to any point in the CharSequence.
    'uncle_alice' is the regex king round here so listen to him.
    :-( I should read further ahead next time!
    Message was edited by:
    sabre150
    Message was edited by:
    sabre150

  • Regular expressions and string matching

    Hi everyone,
    Here is my problem, I have a partially decrypted piece string which would appear something like.
    Partially deycrpted:     the?anage??esideshe?e
    Plain text:          themanagerresideshere
    So you can see that there are a few letter missing from the decryped text. What I am trying to do it insert spaces into the string so that I get:
                        The ?anage? ?esides he?e
    I have a method which splits up the string in substrings of varying lengths and then compares the substring with a word from a dictionary (implemented as an arraylist) and then inserts a space.
    The problem is that my function does not find the words in the dictionary because my string is only partially decryped.
         Eg:     ?anage? is not stored in the dictionary, but the word �manager� is.
    So my question is, is there a way to build a regular expression which would match the partially decrypted text with a word from a dictionary (ie - ?anage? is recognised and �manager� from the dictionary).

    I wrote the following method in order to test the matching using . in my regular expression.
    public void getWords(int y)
    int x = 0;
    for(y=y; y < buff.length(); y++){
    String strToCompare = buff.substring(x,y); //where buff holds the partially decrypted text
    x++;
    Pattern p = Pattern.compile(strToCompare);
    for(int z = 0; z < dict.size(); z++){
    String str = (String) dict.get(z); //where dict hold all the words in the dictionary
    Matcher m = p.matcher(str);
    if(m.matches()){
    System.out.println(str);
    System.out.println(strToCompare);
    // System.out.println(buff);
    If I run the method where my parameter = 12, I am given the following output.
    aestheticism
    aestheti.is.
    demographics
    de.o.ra.....
    Which suggests that the method is working correctly.
    However, after running for a short time, the method cuts and gives me the error:
    PatternSyntaxException:
    Null(in java.util.regex.Pattern).
    Does anyone know why this would occur?

  • Regular Expression Fails String replaceAll

    I am trying to use regular expressions to replace double backslashes in a string with a single backslash character. I am using version 1.4.2 SDK. Upon invoking the replaceAll method I get a stack trace. Does this look like a bug to anyone?
    String s = "text\\\\";  //this results in a string value of 'text\\'
    String regex = "\\\\{2}";  //this will match 2 backslash characters
    String backslash = "\\";
    s.replaceAll(regex,backslash); java.lang.StringIndexOutOfBoundsException: String index out of range: 1
         at java.lang.String.charAt(String.java:444)
         at java.util.regex.Matcher.appendReplacement(Matcher.java:551)
         at java.util.regex.Matcher.replaceAll(Matcher.java:661)
         at java.lang.String.replaceAll(String.java:1663)
         at com.msdw.fid.fitradelinx.am.client.CommandReader.read(CommandReader.java:55)
         at com.msdw.fid.fitradelinx.am.client.CommandReader.main(CommandReader.java:81)
    Exception in thread "main"

    Skinning the cat -
    public class Fred12
        public static void main(String[] args)
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "[\\\\]{2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(\\\\){2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(?:\\\\){2}";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "(?:\\\\)+";  //this will match 2 or more backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
                String s = "text\\\\";  //this results in a string value of 'text\\'
                String regex = "\\\\\\\\";  //this will match 2 backslash characters
                String backslash = "\\\\";
                System.out.println(s.replaceAll(regex,backslash));
    }

  • Regular expression: Split String

    Hi everybody,
    I got to split a string when <b>'</b> occurs. But the string should <u>not</u> be splitted, when a <b>?</b> is leading the <b>'</b>. Means: Not split when <b>?'</b>
    How has the regular expression to look like?
    This does NOT work:
    String constHOCHKOMMA = "[^?']'";
    <u>Sample-String:</u>
    String edi = "UNA'UNB'UNH?'xyz";
    Result should be
    UNA
    UNB
    UNH?'xyz
    Thanks regards
    Mario

    Hi
    I think u can meke it in two ways
    1. using split function u r giving single quote as your delimiter, after each split funcction just add one more split function with delimiter as ?, if it returns true add the previous splited string and next one
    2.  you are gooing through each and every char  of your string  and split when next single quote occur, for this u are comparing each of your char with ['] i believe,
    just compare the char with '?' if it match ignore next single quote.
    Regards
    Abhijith YS

  • Regular Expression on String

    Hi Experts,
    I am working on jdev 11.1.1.6.0
    I have to validate input text, which user can able to enter alpha number with separated by ','.  for example TP103,TP104,TP105........ or 1023,1034,1034....... But they shouldn't enter single ',' or ,,,,,,,,,,,,,,,  . Can any one tell me how to write regular expression for this.
    Thanks.

    user can able to enter alpha number with separated by ','.
    But they shouldn't enter single ',' or ,,,,,,,,,,,,,,,
    Is a ',' required to be validated using a regular expression?
    Refer
    Lesson: Regular Expressions (The Java&amp;trade; Tutorials &amp;gt; Essential Classes)

  • Regular Express in String.replaceFirst(..)

    I have the following string...
    "this ? is what ?."
    I am trying to replace the ? with an element. What is a regualr expression that would allow me to replace the just first ? with an item. I tried "?" but it say dangling reference... Ideas? The ?'s will be diffrent so I will use replace first. I could use substring and indexof and concatenate strings but I would perfer not to do so.
    String str = "this ? is what ?.";
    Object  o = "katz";
    str = str.replaceFirst("?", o.toString());TIA
    Doopsterus

    ? is a special character--a quantifier--that means "match zero or one of the preceding element". If you want to use it literally, you need to escape it with a backslash. Since the backslash is special in Java string literals, you have to escape the backslash so that one gets through to the regex Pattern.
    Try this: str = str.replaceFirst("\\?", whatever);

  • An additional question about regular expressions with String.matches

    does the String.matches() method match expressions when some substring of the String matches, or does it have to match the entire String? So, if i have the String "123ABC", and i ask to match "1 or more letters" will it fail because there are non-letters in the String, but then pass if i add "1 or more letters AND 1 or more digits"? so, in the latter every character in the String is accounted for in the search, as opposed to the first. Is that correct, or are there ways to JUST match some substring in the String instead of the whole thing? i WILL make some examples too... but does that make sense?

    It has to match the whole String. Use Matcher.find() to match on just a sub-string()

  • Using a regular expression in String's split method

    I have a String that is delimited by commas that I would like to split into a String array. However, the problem is that it is valid that some of the elements could have embeded commas in them. These "extra" commas are always in a predefined pattern though.
    For example, the String that I want to parse may look like this (quotes omitted):
    data with spaces and tabs , more data with more spaces, now for the problem(5,9), and now some more text and spaces
    What I would like the result to be (shown below as if each element has been trimmed):
    data with spaces and tabs
    more data with more spaces
    now for the problem(5,9)
    and now some more text and spaces
    string.split("[,&&[^[\\(.,.\\)]]]");The idea being that I want to split on all commas except those that are in the pattern (5,9). Where 5 and 9 could be any integer.
    The above expression isn't working. It isn't ignoring the comma in the pattern.
    Any suggestions?
    Thanks.

    i dunno if this help...
    There is a class called the StringTokenizer class where it splits the String and delimiter up..e.g
    String s1="Hello,Welcome,Can";
    String[ ] arr=new String[3];
    To use the StringTokenizer, you create.
    StringTokenizer st=new StringTokenizer(s1,",");
    //this will split the words, hello,welcome and can into "Tokens"
    Then use this method .hasMoreTokens( )
    int i=0
    while(st.hasMoreTokens( ) ==true) {
    arr=st.nextToken( );
    i++;
    Hope this helps! =)

  • Regular expressions in String.replaceAll()

    Hi,
    I'm trying to implement automatic contextual links on a site.
    What I want is to parse a text (containing HTML tags) and replace every occurence of a word by a link.
    e.g., the text:
    "This is a test text for replacement".
    would be replaced by
    "This is a <a href="www.test.com">test</a> text for replacement".
    Now, obviously I don't want to just do a replaceAll("test", link) because it would also replace things like "contest".
    So I'm trying to detect everytime my keyword "test" is not surrounded by literals, which I can do with the regex \Wtest\W.
    But how can I use replaceAll() to make the application replace just the central bit and leave whatever non literal stuff is around ?
    Or maybe there is a better way of doing this ?
    Any idea will be welcome.
    Thanks

    Why are you makint it so complicated?
    public class Test {
         public static void main(String[] args) throws Exception {
              String text = "This is a test text for replacement";
              text = text.replaceAll(" (test) ", " <a href=\"www.test.com\">$1</a> ");
              System.out.println("After first pass " + text);
              text = text.replaceAll(" (test) ", " <a href=\"www.test.com\">$1</a> ");
              System.out.println("After second pass " + text);
    }But I agree with Sabre. You probably don't want to do several passes over the same data.
    Kaj

  • Regular Expressions and string handling

    I'd like to be able to make a method that takes a String and removes certain substrings from that string. What I'm doing is that I'm getting some text from the internet (an HTML doc) and I'd like to remove all the tags from it.
    my method is:
         String DeTokenString(String s)
    String t=new String(s.replaceAll("<regex>",""));
              return t;
    What would I put in place of <regex> to remove all html tags? s has already had its leading and following whitespace removed elsewhere with .trim() before being passed to DeTokenString.
    Is there any other simple way to accomplish this?

    It does on whatever manages to get through my 17
    firewall, hand-woven packet destroyers, and
    titanium-lead armor.So! That is your final defense mechanism. Bwah hah hah hah hah! Now I have you. That was all I needed to improve my 17-firewall-sneaking-through, hand-woven-packet-destroyer-unweaving, titanium-lead-armor-piercing virus!
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Regular expression matches string starts with &

    Hello,
    I am trying to write a Reg Exp that removes any string starts with "&" and Ends with ";" . In other words, I am trying to remove anything similar to:
    & nbsp;  & quot; & lt; & gt;  Any help please.
    This does not work:
    select regexp_replace(ename, '^&[a-z]{2,4}[;]$') from emp;Regards,
    Fateh

    Fateh wrote:
    I am trying to write a Reg Exp that removes any string starts with "&" and Ends with ";" . In other words, I am trying to remove anything similar to:
    & nbsp;  & quot; & lt; & gt; 
    Those are entity references (without the whitespace after '&').
    Do you really want to remove them, or do you actually want to convert them back to their corresponding characters but don't know how to do it?
    SQL> set scan off
    SQL> select utl_i18n.unescape_reference('&#38;quot;Test&#38;quot;:&#38;nbsp;3&#38;gt;2') from dual;
    UTL_I18N.UNESCAPE_REFERENCE('&
    "Test": 3>2

  • Trying to use regular expressions to convert names to Title Case

    I'm trying to change names to their proper case for most common names in North America (esp. the U.S.).
    Some examples are in the comments of the included code below.
    My problem is that *retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");* does not work as I expect. It seems that the toUpperCase method call does not actually do anything to the identified group.
    Everything else works as I expect.
    I'm hoping that I do not have to iterate through each character of the string, upshifting the characters that follow spaces.
    Any help from you RegEx experts will be appreciated.
    {code}
    * Converts names in some random case into proper Name Case. This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * DAN MARINO --> Dan Marino
    * old macdonald --> Old Macdonald &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * ROY BLOUNT, JR. --> Roy Blount, Jr.
    * CAROL mosely-BrAuN --> Carol Mosely-Braun
    * Tom Jones --> Tom Jones
    * ST.LOUIS --> St. Louis
    * ST.LOUIS, MO --> St. Louis, Mo &lt;-- Avoid City Names plus State Codes
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
    * Basic plan:
    * 1. Strategically create double spaces in front of characters to be capitalized
    * 2. Capitalize characters with preceding spaces
    * 3. Remove double spaces.
    // Make the string all lower case
    String retName = name.trim().toLowerCase();
    // Collapse strings of spaces to single spaces
    retName = retName.replaceAll("[ ]+", " ");
    // "mc" names
    retName = retName.replaceAll("( mc)", " $1");
    // Ensure there is one space after periods and commas
    retName = retName.replaceAll("(\\.|,)([^ ])", "$1 $2");
    // Add 2 spaces after periods, commas, hyphens and apostrophes
    retName = retName.replaceAll("(\\.|,|-|')", "$1 ");
    // Add a double space to the front of the string
    retName = " " + retName;
    // Upshift each character that is preceded by a space
    // For some reason this doesn't work
    retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");
    // Remove double spaces
    retName = retName.replaceAll(" ", "");
    return retName;
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:56 AM
    Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:57 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hopefully someone will still be able to provide a RegEx solution, but until that time here is a working method.
    Also, if people have suggestions of other rules for letter capitalization in names, I am interested in those too.
    * Converts names in some random case into proper Name Case.  This method does not have the
    * extra processing that would be necessary to convert street addresses.
    * This method does not add or remove punctuation.
    * Examples:
    * CAROL mosely-BrAuN --&gt; Carol Mosely-Braun
    * carol o'connor --&gt; Carol O'Connor
    * DAN MARINO --&gt; Dan Marino
    * eD mCmAHON --&gt; Ed McMahon
    * joe amcode --&gt; Joe Amcode         &lt;-- Embedded "mc"
    * mr.t --&gt; Mr. T                    &lt;-- Inserted space
    * OLD MACDONALD --&gt; Old Macdonald   &lt;-- Can't capitalize the 'D" because of Ernst Mach
    * old mac donald --&gt; Old Mac Donald
    * ROY BLOUNT,JR. --&gt; Roy Blount, Jr.
    * ST.LOUIS --&gt; St. Louis
    * ST.LOUIS,MO --&gt; St. Louis, Mo     &lt;-- Avoid City Names plus State Codes
    * Tom Jones --&gt; Tom Jones
    * This is a work in progress that will need to be updated as new exceptions are found.
    public static String toNameCase(String name) {
         * Basic plan:
         * 1.  Strategically create double spaces in front of characters to be capitalized
         * 2.  Capitalize characters with preceding spaces
         * 3.  Remove double spaces.
        // Make the string all lower case
        String workStr = name.trim().toLowerCase();
        // Collapse strings of spaces to single spaces
        workStr = workStr.replaceAll("[ ]+", " ");
        // "mc" names
        workStr = workStr.replaceAll("( mc)", "  $1  ");
        // Ensure there is one space after periods and commas
        workStr = workStr.replaceAll("(\\.|,)([^ ])", "$1 $2");
        // Add 2 spaces after periods, commas, hyphens and apostrophes
        workStr = workStr.replaceAll("(\\.|,|-|')", "$1  ");
        // Add a double space to the front of the string
        workStr = "  " + workStr;
        // Upshift each character that is preceded by a space and remove double spaces
        // Can't upshift using regular expressions and String methods
        // workStr = workStr.replaceAll("( [^ ])([^ ]+)", "$1"toUpperCase() + "$2");
        StringBuilder titleCase = new StringBuilder();
        for (int i = 0; i < workStr.length(); i++) {
            if (workStr.charAt(i) == ' ') {
                if (workStr.charAt(i+1) == ' ') {
                    i += 2;
                while (i < workStr.length() && workStr.charAt(i) == ' ') {
                    titleCase.append(workStr.charAt(i++));
                if (i < workStr.length()) {
                    titleCase.append(workStr.substring(i, i+1).toUpperCase());
            } else {
                titleCase.append(workStr.charAt(i));
        return titleCase.toString();
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Remote for 2gen Touch

    Does anyone know of a reliable remote to use with a 2nd gen. Touch? I have the Monster iEZClick, but it stopped working when I upgraded to iOS4. I already changed the battery in the iEZClick remote with no luck. I also am not interested in the earbud

  • Delivery note cancellation in case of proforma invoice

    Hi SAP Gurus I am in a typical automotive industry project where stock transfer takes place from factory to Sales Depo. In thsi case we generate STO orders - delivery note-- PGI-  Proforma invoice--- Excise invoice . Now as no accounting documents ar

  • IMac hard drive is clicking and keeps crashing

    Am really getting quite concerned about my imac. It's 3 years old (Apple protection plan just ended a month ago!!) and over the last month or so I've noticed it keeps making a loud clicking noise coming from the hard drive (righthand side if the comp

  • How to clean uninstall firefox on mac OS X 10.10.1

    Attempt to uninstall Firefox on my iMac has left "mozilla.org" and "mozilla.net" in my cache. I've tried to remove it by clearing history and website data but it refuses to go away. How do I get rid of it and get back to where I was before trying to

  • ECC 6.0 compare programs - stuck in split screen editor

    In ECC 6.0, I went into version management and compared two versions of an ABAP source.  In settings, I selected to go into the split-screen editor.  Now I'm stuck.  Whenever I select to compare two versions of any program, it brings up the split-scr