How to include /(Forward slash) in my regular expression

Hai All,
I am having a regular expression which should accept only A-Z,0-9, _(underscore) and .(period) .
<property name="patterns" value="[A-Z0-9\\._]*" />
Now i need to add /(Forward slash) to this expression.
<property name="patterns" value="[A-Z0-9\\._/]*" />
But when i add it it is accepting both Foward slash and Backward slash.
Can someone guide me such that it accepts only A-Z, 0-9, Underscore, period and a Forward slash(/).
Thx in advance..

sabre150 wrote:
Your regex without the / was accepting \ since '.' does not need to be escaped inside a character class. Just remove the \\ .And if you really did need to escape the dot, you would only have to use one backslash, not two: <property name="patterns" value="[A-Z0-9\._/]*" /> In Java source code you would have to use two backslashes because one of them gets consumed by the Java compiler. But this is obviously an XML file, so that rule doesn't apply. But, as Sabre pointed out, you don't need a backslash there at all: <property name="patterns" value="[A-Z0-9._/]*" />

Similar Messages

  • How to include a forward slash(/) in my regular expression

    Hai All,
    I am having a regular expression which should accept only A-Z, 0-9, (underscore) and .(period) .
    <property name="patterns" value="[A-Z0-9\\._]*" />
    Now i need to add /(Forward slash) to this expression.
    <property name="patterns" value="[A-Z0-9\\._/]" />
    But when i add it it is accepting both Foward slash and Backward slash.
    Can someone guide me such that it accepts only A-Z, 0-9, Underscore, period and a Forward slash(/).
    Thx in advance..

    Looks like you had it right to me.
    import java.util.regex.Pattern;
    import junit.framework.TestCase;
    public class RegexTest extends TestCase{
         public String patternString = "[A-Z0-9\\./]*";
         public void testRegex(){
              Pattern pattern = Pattern.compile(patternString);
              assertTrue(Pattern.matches(patternString, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
              assertFalse(Pattern.matches(patternString, "abc"));
              assertTrue(Pattern.matches(patternString, "24.7"));
              assertTrue(Pattern.matches(patternString, "24/7"));
              assertFalse(Pattern.matches(patternString, "21\\7"));
    }It works in my tests.
    What happends to this "patterns" property? Where and how are you using it?

  • How to get the meaning of the regular expression?

    Hello All,
    I want to know how to get the meaning of the regular expression?
    The requirement is i need to get the regular expression for some of the attributes and if the value is not matching with that regular expression then i need to give the popup saying the limitation of the attribute. but i need to give the pop up with the user understanding format.
    Like "please give a to z or 1 to 9" like that.
    So is there any way Java will help me to get the meaning of the regular expression?
    Thank You!
    Arun S

    I'm not aware of any such tool or library.
    Also, it would be a terrible "explanation", because regular expressions (similar to other programming languages) have their own "style" of defining what to enter and that usually doesn't translate well into natural language.
    For example the regex "[a-z][a-z0-9]*\s+[a-z0-9]+" could be translated as "a to z, followed by zero or more characters from a to z or 0 to 9 followed by any amount of whitespace followed by one or more characters from a to z or 0 to 9".
    Or you could simply say "Please enter two alphanumeric words, the first one must not start with a number".
    My suggestion: store/configure the human-readable description together with the regex. Don't try to automate it.

  • How to include Forward button dynamically using code?

    hello,
    i am creating my notification message dynamically using clob type document type attribute , and its working fine. But how i include the Forword Button in my message body.
    please advice

    i am allready doing that only, in that what will be the name of the button.
    can i put like this.
    htp.p( '<input type="button" name="forward">');
    then what about the event, shall i have to write the code for forward also.
    please advice.

  • How to Capture Multiple Line String using Regular Expression?

    Hi, 
    I have a simple program like this:
    What I want to accomplish is to capture everything between >>start and >>end using a single Match Regular Expression node. It seems that setting multiple? to True or False does not help.
    I am using LabVIEW 2012.
    If it is impossible to capture it using a single node, that is fine. But I want to make sure that I can make full use of this node without combining serveral others.
    Thank you!
    TailOfGon
    Certified LabVIEW Architect 2013
    Solved!
    Go to Solution.

    Thank you for the fast response! Your solution worked in the example case
    After I saw your post, I was finally able to step forward. But I still wanted to make use of dot notation due to the limitation of characters that match with \w. 
    I made some more modification to your regular expression then now it seems working for all characters:
    >>start((?:\s|.)*)>>end
    Thanks!
    TailOfGon
    Certified LabVIEW Architect 2013

  • How to get mathched amount in a regular expression?

    Is there any direct method to know the matched amount in a regular expression? I don't know but have to loop for the Matcher object and count. Too inconvenient !
    thanks.

    sabre150 wrote:
    fxbird2 wrote:
    Is there any direct method to know the matched amount in a regular expression? Define please. Do you mean a 'group' ?
    I don't know but have to loop for the Matcher object and count. Too inconvenient !Since I don't understand what you mean by "the matched amount" I can't tell if this is correct or not.
    You could always produce an SSCCE and ask how it might be improved.No,no,no, just means matched substring, like 2 is the matched amount for "aaabbaa" by "aa".

  • How do I have to define a regular expression to filter out data from file?

    Hi all,
    I need to extract parts of lines of a ASCII file and didn't get it done with my low knowledge of regular expressions
    The file contains hundreds of lines and I am just interested in a few lines, within that lines I just need a part of the data.
    One original line looks like that:
    TP3| |TP_SMD|Nicht in Stueckliste|~TP TP_SMD TESTPUNKT|-|0|87.770|157.950|0|top|c| |other|TP_SMD|TP_SMD_60RF-TP
    Only the bold and underlined information is of interest, I don't need the rest.
    I can open that file, read in each line but then I am struggling to pick out only the lines of interest (starting with TP), taking that TP with its number and the coordinates following later on and then writing these shortened lines to a new text file. So the new line should look like that:
    TP3; 87.770;157.950;0 (It doesn't matter if the separator will be ; or |)
    I thought of using regular expressions - is that the right way or is there a better approach?
    Thanks & regards,
    gedi, using LabVIEW 8.5
    Regards,
    gedi

    Hi max,
    for finding a specific part of a string you can use the "Match Pattern" VI, it is located in the Strings Palette.
    Maybe the Extract Numbers.vi example in the examples browser library can help you.
    What I did to filter out my data of interest is first to sort out only the columns which I want to have -
    then there are still a lot of lines remaining I don't need (this is the thing described above).
    The rest I am going to filter out with a (then easy) regular expression with the "Match Pattern" VI.
    Regards,
    gedi
    Regards,
    gedi

  • How do I forward ports on my Airport Express?

    I've been trying to get my ports open for a while now, but haven't succeeded. Here's my setup:
    I have an Airport Express connected to a Dynalink RTA1320 ADSL2+ modem. I am running 10.5.2.
    On the Dynalink modem, I have set 10.0.1.1 as a DMZ host, which is the address of the Airport Express.
    I understand that in Airport Utility, I need to set private and public ports, as well as IP address. I am using NPMP with the Airport Express, and I have a default host set as 10.0.1.253. This is the IP address I am using on my Mac, and the one that I am using when forwarding ports on the Airport Express.
    Even after doing all this, online port checkers still say that the ports I have forwarded are closed, and I can't work out why.
    However: I am using XTorrent as my BitTorrent client. I have the port 49350 set as the default port in that application. XTorrent has the ability to open ports by itself, and it seems to have succeeded at doing this, even though I cannot open other ports manually. 49350 reads as open when using an online port checker.
    These are the questions I have:
    1. Am I inputting the right IP addresses?
    2. Is NPMP doing me any good, or should I be using straight DHCP?
    3. Am I doing the right thing by setting 10.0.1.1 as a DMZ?
    4. Am I doing anything else wrong?
    Thanks very much for your input in advance.

    On the Dynalink modem, I have set 10.0.1.1 as a DMZ host, which is the address of the Airport Express.
    This is probably incorrect. 10.0.1.1 is the LAN IP address of the AirPort Express (AX). You want to use the IP address provided by the Dynalink to the AX. It is the IP address used on the WAN side of the AX.
    ...Airport Express, and I have a default host set as 10.0.1.253.
    If you configure the AX for Default Host operation, ALL of the ports are forwarded to the assigned IP address. The is no other configuration needed to forward the ports.

  • How to use forward slash in a string

    ok, this is probably very simple, but i have a url that i need to pass into my app that looks like:
    public void resize(URL url, String id)
    }I'm trying to pass it a simple address of an image stored somewhere on the net but i am just faced with this instead:
    class java.lang.NoSuchMethodError
    resizeImage.resizeImage.resize(Ljava/lang/String;Ljava/lang/String;)V
    Now i know that this is because there is something wrong with the arguments being passed into the method, which i'm doing like this:
    imgManip.resize("http://www.screwfix.com/sfd/i/cat/59/p3248959_x.jpg","99"); what am i doing wrong?

    Is a String a URL? Answer: No.
    Create a URL from that string.

  • One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?

    How to get the below output using REGULAR EXPRESSIONS??
    SQL> ed
    Wrote file afiedt.buf
      1* CREATE TABLE cus___addresses    (full_address                   VARCHAR2(200 BYTE))
    SQL> /
    Table created.
    SQL> PROMPT Address Format is: House #/Housename,  street,  City, Zip Code, COUNTRY
    House #/Housename,  street,  City, Zip Code, COUNTRY
    SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
    1 row created.
    SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
    1 row created.
    SQL> SELECT * FROM cus___addresses;
    FULL_ADDRESS
    1, 3rd street, Lansing, MI 49001, USA
    3B, fifth street, Clinton, OK 74103, USA
    Rose Villa, Stanton Grove, Murray, TN 37183, USA
    SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AM

    Hi,
    user12240205 wrote:
    ... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
    Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
    Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
    '.*' means "0 or more of any character".
    '\D*' means "0 or more non-digits".
    The whole expression, '.*(\d{5})\D*' means:
    a. 0 or more characters (any characters)
    b. 5 digits
    c. 0 or more non-digits.
    '\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
    So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone."

  • 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

  • Searching in reverse with regular expressions

    I have recently constructed a "Find" dialog for my editor and would like to support the use of regular expressions (for people who know more about them than I do.) I have radio buttons that allow the user to search down (from the current caret position to the end of the document) or up (from the current caret position to the beginning of the document.)
    I have it working fine with literal text via String.indexOf() and String.lastIndexOf(), but I'm not sure how to implement an "upwards" search using regular expressions. It seems that java.util.regex only provides for searching from the current caret position downwards. Any suggestions?

    two not-very-good-for-big-document suggestions
    1) search up by searching down (from the beginning) to the last match before the position searched from
    2) when the user asks for a search find all matches, number them and keep the index in the doc where they were found, then look up the largest index less than the carets index
    you might try constructing succesively larger strings that end at the current caret position, and matching them one by one. If you're near the bottom, and theres no matches, this is also likely to be sloow..
    asjf

  • 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

  • Regular expression and output format

    hi all,
    i have following scenario-
    regular expression: [0-9]{3}-[0-9]{3}-[0-9]{4}
    generated value by the above regular expression: 123-234-6789
    output format to display the generated above value: xxx-xxx-$1
    now i need to display the generated value (123-234-6789) in the specified output format (xxx-xxx-$1) and the final output will be xxx-xxx-6789
    how is it possible?
    Note: here regular expression and output format can vary
    br,
    bashar

    Hi, Bashar
    You can solve this problem by using the Data Masking Technique.
    Masking data means replacing certain fields with a Mask character (such as an X). This effectively disguises the data content while preserving the same formatting on front end screens and reports. For example, a column of credit card numbers might look like:
    4346 6454 0020 5379
    4493 9238 7315 5787
    4297 8296 7496 8724
    and after the masking operation the information would appear as:
    4346 XXXX XXXX 5379
    4493 XXXX XXXX 5787
    4297 XXXX XXXX 8724
    The masking characters effectively remove much of the sensitive content from the record while still preserving the look and feel. Take care to ensure that enough of the data is masked to preserve security.
    It would not be hard to regenerate the original credit card number from a masking operation such as: 4297 8296 7496 87XX since the numbers are generated with a specific and well known checksum algorithm.
    Best Regards,
    Mahfuz Khan

  • Regular Expression Validator

    Are there plans to include a validator based on regular expressions in the first releae of JSF. I can imagine many consumers of JSF writing their own if one isn't provided out of the box. I know .NET has such a thing.

    I would also like to vote for such a thing.
    Does anyone know whether the JSF crew is reading these posts?
    I was really wondering why this validator is missing and I fear that it is missing because some JSF people don't want one, since otherwise having a regexp validator would be the most intuitive validator to have.
    Some frameworks combine regexp matching with internationalization and localization. This is one aspect that does not really have to be considered with the validators out so far. Maybe that is the reason for why the RegexpValidator is missing.
    Also, since JSF needs to be compatible to JDK1.3, there would have to be an extra regexp package like oro to be included within the faces implementation. And someone would have to write a validator using this package for jdk1.3 and another one using the jdk1.4 buildin regexp package. Maybe that's why there is not yet one available...

Maybe you are looking for