Allow specific characters - Regular Expression

Hello everyone
I am new to regular expression and I have a very simple question. I use the "read from text file" function to load a Tab delimited file with 3 columns into my VI. Next, the string is converted in array and I use the values.
Nevertheless, I want to develop a "filter" allowing only digits (0-9), colon, comma and point into strings.
Using the "match regular expression" function, I was trying a regular expression like that:
[^0-9]|[^\].[|^:]|[^,]
But it is not working.
Could someone help me with this issue?
Thanks
Dan07
Solved!
Go to Solution.

Hello
Actually I don't need to modify the string that has "invalid" characters, I just need to identify them instead. Find below a VI testing both methods: Match Regular Expression and Search and Replace String.
Using Match Regular Expression method, I got correct results since all the "valid" values must be identified as "-1" and all the "invalid" values must be identified as positive numbers (offset).
Nevertheless, using Search and Replace String method I got wrong results, since all the strings were classified as "valid" (-1), but "bg" and "03/12/2010" are not "valid".
I will go ahead with Match Regular Expression method because it is working great, but I was just wondering how to fix Search and Replace String method to achieve equivalent results.
Thanks
Dan07
Attachments:
Regular Expression_example.vi ‏18 KB

Similar Messages

  • Infopath throws error "only specific pattern allowed" when use regular expression for validation in schema

    This is MS info path question, I could not find specific forum for Info-Path So asking my question here
    I am creating Info-Path form from schema. In the schema, the filename has restriction that it can only have extension .pdf or .PDF. But while filling out the form even if I type filename with extension ".pdf", I still see error "only
    specific pattern allowed".
    Below is my schema I used to create form
    <?xml version="1.0" encoding="utf-8" ?>
    <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="Document">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="FileName" type="FileNameType"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:simpleType name ="FileNameType">
    <xs:restriction base="xs:string">
    <xs:pattern value="^.*\.(pdf|PDF)$"/>
    <xs:minLength value="1" />
    <xs:maxLength value="128" />
    </xs:restriction>
    </xs:simpleType>
    </xs:schema>

    Hi
    This is the forum to discuss questions about Microsoft Office development. For your question, I recommend you post the question to the Answers forum for Infopath
    Microsoft Community for​ InfoPath​
    By the way, you can get support from here.  Support for Microsoft InfoPath
    Thank you for your understanding.
    Best Regards
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to use special characters in regular expression

    HI all, I am new to regular expression.
    Can any one please tell me the regular expression for characters which are used in regular expression like " [({. tetc.Is there any particular expression to prefix before using these characters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Expression:
    < td .*? bgcolor = \" ( [^ \" ] +) \" \\s* .*? > ( .+? ) </td>
    It will search for expression starting with <td ,
    .*? means any characters zero or more than one,
    then it will find bgcolor = , then literal \"... \(any char) is that specific char
    [ ^ \" ] any character but not literal \",this means there has to be something between ".... " if empty then wont match ,+ is 1 or more times
    Then again literal \ " , after that \\s* means zero or more num of spaces,
    then again , .*? means any characters zero or more than one,
    it will search for literal > , again any chars . * ?
    Finally </td> will be searched.....!!
    So all expressions having this particular structure will be
    matched.
    Output :
    <td align="left" valign="top" bgcolor="ffffff" width="177">bla bla bla</td>

  • String Regular Expression for uncommon characters

    Hi,
    I am trying to get text out of HTML file for which I am using EditorKit and Document classes. After I obtain the text, the text (String) contains some characters like �. This character looks like a with French style acute accent . My problem is how to use regular expression to find and replace (replaceAll method) these unwanted characters.
    Is there a regular expression pattern for such characters?
    Thanks!
    Rahul.

    hrm I would recommend looking at the specific patterns,
    a simplified site would be here http://www.p3m.org/wiki?regex
    as a refernce . If you dont know regular expression, use
    http://www.perl.com/doc/manual/html/pod/perlre.html
    The only way I could think of constructing the regex is to use the \s and add the characters you want in that regex :s you could look into regex look ahead and look behind methods...

  • Regular Expression Exclude Certain Characters

    I am building this with Apex 3.2
    I have a validation on a page item of type regular expression
    Validation Expression 1 :   P13_TARGET_BMI
    Validation Expression 2:    ^[[:alnum:]-]*$
    This allows all characters, number and the - symbol
    Now I need to exclude certain alpha characters, ie German letters Ä Ü Ö
    and spaces if possible
    Basically if the user types in Ä, Ü, Ö, the validation should fail
    Cheers
    Gus

    Hi, Gus,
    The most efficient thing would be to list all the acceptable characters instead of using [:alnum:].
    REGEXP_LIKE ( str
                , '^[a-z0-9A-Záéíóúæ... -]+$'
    If you can't do that, then use a separate test to check for the exceptional alphabetic characters
         REGEXP_LIKE ( str
                     , '^[[:alnum:] -]+$'
    AND  str = TRANSLATE ( str
                         , 'xÄÜÖ'
                         ,'x'
    You can use regular expressions for the Ä Ü Ö testing, if you want to.
    There's nothing tricky about spaces; by default, they have no special meaning in regular expressions, and they never have any special meaning inside square brackets.

  • Regular Expressions and Double Byte Characters ?

    Is it possible to use Java Regular Expressions to parse
    a file that will contain double byte characters ?
    For example, I want a regular expression to match the following line
    tag="double byte stuff" id="double byte stuff"

    The comments on the bytes/strings were helpful. Thanks.
    But I'm still confused as to what matching pattern could be used.
    For example a pattern like:
    [A-Za-z]
    I assume would not match any double byte characters.
    I also assume the following won't work either:
    [\\p{Alpah}]
    because it is posix - US-ASCII only.
    So how do you say "match the tag, then take any characters,
    double byte, ascii, whatever, then match the text tag - per the
    original example ?

  • Regular expressions-how to replace [ and ] characters from a string

    Hi,
    my input String is "sdf938 [98033]". Now from this given string, i would like to replace the characters occurring within square brackets to empty string, including the square brackets too.
    my output String needs to be "sdf938" in this case.. How should I do it using regular expressions? I tried several possible combinations but didn't get the expected results.

    "\\s*\\[[^\\]]+\\]"

  • Converting String Characters into Regular Expression Automatically?

    Hi guys.... is there any program or sample coding which is available to convert string characters into regular expression automatically when the program is run?
    Example:
    String Character Input: fnffffffffffnnnnnnnnnffffffnnfnnnnnnnnnfnnfnfnfffnfnfnfnfnfnnnnd
    When the program runs, it automatically convert into this :
    Regular Expression Output: f*d

    hey guys.... i am sorry for not providing all the information that you guys need as i was rushing off to urgent meeting... for my string characters i only have a to n.. all these characters are collected from sensors and stored inside database... from many demos i have done... i found out that every demo has different strings of characters collected and these string of characters will not match with the regular expressions that i had created due to several unwanted inputs and stuff... i have a lot of different types of plan activities and therefore a lot of regular expressions.... if i put [a-z|0-9]*... it will capture all characters but in the same time it will be showing 1 plan only.... therefore, i am finding ways to get the strings i collected and let it form into regular expression by themselves in the program so that it will appear as different plans as output with comparing with the regular expression that i had created.... is there any way to do so?
    please post again if there is any questions u are still not familiar with... thank you...

  • Changeparticular characters in a string by using regular expressions ...

    Hello Everyone,
    I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
    My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
    Is it possible by using regular expressions in oracle ?
    Can you give me some clues ?
    Thank you

    SSU wrote:
    Hello Everyone,
    I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
    My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
    Is it possible by using regular expressions in oracle ?
    Can you give me some clues ?
    Thank you
    SQL> SELECT
      2  regexp_replace('sdfsdf Sdfdfs Sdfd','s|S','X') from dual;
    REGEXP_REPLACE('SD
    XdfXdf XdfdfX XdfdRegards,
    Achyut

  • Regular Expression for finding Latin characters

    i have a table "t" with values in column "text" like
    "Āniki"
    "Ąvatar"
    How can I find them using a regular expression?
    The real goal is to replace them with their ASCII equivalent.
    Ā = A
    Č = C
    Ĥ = H
    etc....

    You can set any range in the ascii table by using the expression 'X-Y' in the pattern. It works for symbols too, but you need to find out whether the desired characters you're interested actually form a contiguous range.
    You can run the below query to check the ascii table:
    SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256;Then you can pick and choose your ranges and verify them as in the following query:
    WITH t AS
    (SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256)
    SELECT ascii_val, chr_column FROM t WHERE regexp_like(chr_column, '[^A-Za-z0-9!-/]');In the example above I chose a range from the ascii 33 ('!') to 47 ('/'), described by the portion '!-/' in the pattern.
    To add another range just concatenate it after the slash symbol.
    Additionally, for example, if you want to add a range including the symbols:
    ASCII CHR
    58    :
    59    ;
    60    <
    61    =
    62    >
    63    ?You can set it up like this instead if you feel it's more easily readable:
    WITH t AS
    (SELECT LEVEL ascii_val, chr(LEVEL) chr_column FROM dual CONNECT BY LEVEL < 256)
    SELECT ascii_val, chr_column
      FROM t
    WHERE regexp_like(chr_column, '[^A-Za-z0-9' ||
                                   chr(33) || '-' || chr(47) ||
                                   chr(58) || '-' || chr(63) ||
                                   ']');You need to test this though, as the docs state the behaviour may vary depending on your NLS_SORT settings, by using linguistic ranges rather than byte values. For my settings it seems to work, not sure about everywhere else.
    Note: In the POSIX standard, a range includes all collation elements between the start and end of the range in the linguistic definition of the current locale. Thus, ranges are linguistic rather than byte values ranges; the semantics of the range expression are independent of character set. In Oracle Database, the linguistic range is determined by the NLS_SORT initialization parameter.http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_regexp.htm
    and
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10729/ch5lingsort.htm
    You can check your NLS_SORT by querying the userenv:
    SQL> select sys_context('USERENV', 'NLS_SORT') from dual;
    SYS_CONTEXT('USERENV','NLS_SOR
    WEST_EUROPEAN
    SQL> If it returns BINARY you need not worry about it.
    Otherwise you can check the particular sorting your NLS_SORT will use here:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10729/applocaledata.htm#NLSPG593
    Usually symbols are not affected by it as you can see there (my case too for the "west_european" value), but other elements in a string can be affected.
    Regards,
    Sitja.
    Edited by: fsitja on Mar 18, 2010 1:51 PM

  • Regular expression - escape characters

    Hi. Is there an escape character for "?", "[", "]", "{", "}" for regular expression? I tried to do the following: "[^[]?{}]*" (the string cannot contain a question mark, left or right bracket, or left or right curly brace). However, I get an error stating unexpected character.
    thanks,
    Paul.

    Hi. Is there an escape character for "?", "[", "]",
    "{", "}" for regular expression? I tried to do the
    following: "[^[]?{}]*" (the string cannot contain a
    question mark, left or right bracket, or left or right
    curly brace). However, I get an error stating
    unexpected character.
    You should only have to escape the characters that cause a problem in the character class, rather than everything so the following should work.
    "[^\\[\\]?{}]*"

  • Regular expression: check for the presence of special characters.

    I have the following requirement:
    I need to check for the presence of the following characters in a keyword: @, #, > if any of these characters are present, then they need to be stripped off, before going further. Please let me know the regular expression to check for these characters.

    I am trying to extend the same logic for the following characters:
    .,‘“?!@#%^&*()-~<>[]{}\+=`©® . here is the code fragment:
    Pattern kValidator = Pattern.compile("[\\.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]");
    Matcher kMatcher = kValidator.matcher(keyWord);
    if (kMatcher.find(0)) {
    keyWord = keyWord.replaceAll("[.,\\‘\\“?!@#%^&*()-~<>[]{}\\+=\\`©®]", " ");
    }I get the following error. This error is from the weblogic command window. I dont understand these special characters.
    Error:
    28 Oct 2008 12:27:48 | INFO  | SearchController   | Exception while fetching search results in controller:Unclosed character class near index
    39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
    java.util.regex.PatternSyntaxException: Unclosed character class near index 39
    [\.,\&#915;Çÿ\&#915;Ç£?!@#%^&*()-~<>[]{}\+=\`&#9516;&#8976;&#9516;«]
                                           ^
            at java.util.regex.Pattern.error(Pattern.java:1650)
            at java.util.regex.Pattern.clazz(Pattern.java:2199)
            at java.util.regex.Pattern.sequence(Pattern.java:1727)
            at java.util.regex.Pattern.expr(Pattern.java:1687)
            at java.util.regex.Pattern.compile(Pattern.java:1397)
            at java.util.regex.Pattern.<init>(Pattern.java:1124)
            at java.util.regex.Pattern.compile(Pattern.java:817)

  • Regular Expression - Invalid characters

    I have a varchar2(10) field that I need to query out records that contain any character NOT in the following list of characters.
    1. alpha (any case)
    2. numeric
    3. space
    4. &
    5. - (hypen)
    6. *
    7. . (period)
    8. ' (single quote)
    9. (
    10. )
    11. , (comma)
    12. #
    13. /
    Example:
    When run against the below data it would only select the record with the % in it.
    a8*-
    1234
    a8#kd
    u%oO9
    Thanks

    I get the following error message when I run the example above. When I remove the initial hypen (e.g. where regexp_like(field,'[^a-zA-Z0-9 &*.''(),#/]+');) it runs but I get all rows in the result set. Is this a know Oracle bug --- database is version 10.1.0.5.0?
    Error starting at line 1 in command:
    with t as(
    select 'a8*-' field from dual union all
    select '1234' from dual union all
    select 'a8#kd' from dual union all
    select 'u%9' from dual)
    select * from t
    where regexp_like(field,'[^-a-zA-Z0-9 &*.''(),#/]+')
    Error report:
    SQL Error: ORA-12728: invalid range in regular expression
    12728. 00000 - "invalid range in regular expression"
    *Cause:    An invalid range was found in the regular expression.
    *Action:   Ensure a valid range is being used.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regular Expressions to Omit Characters

    I am new to Java. I am trying to use regular expressions to omit a pattern. The construct [^abc] can be used to omit a or b or c, but how can I omit the string abc from a regular expression? Many thanks.

    Why not use the regular expression "abc" and see if it doesn't match? Or even use this:
    boolean matches = (targetString.indexOf("abc") == -1); // == -1 means "not found", so matches become true if abc is not in targetString
    if (matches) System.out.println("Yay, no abc in " + targetString + "!");
    else System.out.println("Eek, get that abc out of my sight!");

  • Regular expression in java -- specifically email

    Does anyone know how I can do a regular expression with java that is going to retrieve an email address pattern.
    For example, let's say i have a huge string
    this is a sample test. perhaps someoen can tell me how to retrieve my [email protected] from this string. sincerely yours [email protected]
    could someone explain to me how to retrieve these emai addresses most efficiently using java's regular expressions
    thanks
    stev

    A citing (http://jregex.sourceforge.net/examples-email.html):
    String someValidChars="[\\w.\\-]+";
    String someAlphaNums="\\w+";
    String dot="\\.";
    Pattern email=new Pattern(someValidChars + "@" + someValidChars + dot + someAlphaNums);

Maybe you are looking for

  • Save user input data

    I would like the ability to have a settings screen and allow the user to enter parameters.  These parameters need to be saved even when the program (VI) is shut down.  As an example I made a quick simple program, Sample test 1.vi.  Here there is inpu

  • Getting an error message trying to open a file, "Missing required parameter 'from' for method "open'. What do I do?

    Getting an error message trying to open a file, "Missing required parameter 'from' for method "open'. I've tried opening in CC and CS5. What do I do? Can the file be salvaged?

  • Testing Pricing Requirements

    Hy Guys, how do you test the pricing requirements (ex. manual conditions, manual deposit condition, free of charge deposit cond, mixed palled surcharge etc) ??? So you create sales orders, credit memos and so on, and then..? Thank you ! Cris

  • Error when updating to display artwork!!

    I am having a problem with the artwork displaying on my iPod. I go into iTunes and go under iPod options and UNCHECK the box to display the artwork on my iPod. Then click okay. Then, go back into it and CHECK the box TO display the artwork and I get

  • Transfering control between main and a thread

    Hi, How to transfer control from a thread which has been initiated from main, back to main.I have a variable and if the value of the var is true the control should go back to main after performing a task the value of the var is set false and the cont