Regular Expression Pattern

I currently have a RegExp pattern set up with the expression (\w\s\!\$/\(\)\&\.\+\-]+) (there is a [ between the ( and \w but it was showing HTML: instead of [ (maybe the problem?)) but when I try to compile the page, I get an XML-20201: (Fatal Error) Expected name instead of \ error
Does anybody have any idea what I need to change in the regular expression to get it to run in Jdeveloper?
Thanks
Andy

<messageTextInput id="${bindings.ItemCodesCodeDescription.path}" model="${bindings.ItemCodesCodeDescription}" required="yes" readOnly="${jhsUserRoles['ITEMS_RO']}" promptAndAccessKey ="Des&amp;cription" rows="1" maximumLength="50" columns="30">
<onSubmitValidater>
<regExp pattern="(\w\s\!\$/\(\)\&\.\+\-]+)"/> //again, [ between ( and \w
</onSubmitValidater>
</messageTextInput>
It's part of a Description textInput, we want to limit the use of characters because it will be saved to our database

Similar Messages

  • White space in regular expressions (Pattern class)

    Hello,
    I have to check if a String contains ONLY the following characters: a-z, A-Z, ' and ( ) .
    The regular expression that I wanted to use with the Pattern class was [[a-zA-Z][\u0027][\u0028][\u0029][\s]] .
    Now, my compiler (Eclipse) doesnt recognize \s as an expression. Is this the proper expression for a white space?
    Also, in this notation, will the Pattern check for the order of the characters, cause the order isn't supposed to matter.
    I would appreciate any help you could give me on this subject.
    With Best Regards, Roderick

    I'm not a regex expert, but I don't see any of the regex gurus online, and this I can tell you.
    my compiler (Eclipse) doesnt recognize \s as an expressionYou need to escape the backspace in a String literal. Use"\\s"
    in this notation, will the Pattern check for the order of the charactersFor that I think (note:think, not know) you need to put the entire set of characters to be matched in one character class. Could you try this and post back whether it works for your requirement?"[^a-zA-Z'()\\s]"Note the negation operator at the start of the characer class, which will match positive for any character not in the character class.
    db
    edit You can test your regex here:
    {color:0000ff}http://www.dotnetcoders.com/web/Learning/Regex/RegexTester.aspx{color}
    but remember to double the backslashes whe you include it in your java code as a String literal.
    Edited by: Darryl.Burke

  • -Split Regular expression pattern

    Hi all,
    I came across the below example in Lee Holmes' PowerShell Cookbook 3rd editon:
    "Hello World" -split  "He(ll.*o)r(ld)"
    and the output is:
    llo Wold
    Even though I do understand Regular Expressions to some degree (where I can comfortably write a reasonably simple pattern for -replace operator or Select-String cmdlet for example), I am struggling to understand the RE pattern above and what it's trying
    to achieve in the -split context. What are the 2 groupings trying to achieve here while splitting a text? What I want to know is the literal translation of the pattern above in clear English words.
    Any thoughts?

    I guess that explains it clearly now. In fact that's what I wrote above yesterday. So parenthesis in -split operator pattern is not a grouping construct, instead a 'preserving' construct, saving it from consumption by the split operation.
    Therefore, following -match operator pattern-semantics  to understand -split operator will mislead us here.
    But then again, I have troubles understanding the below pattern  
    "Hello World" -split  "(He(ll.*o)r(ld))"Hello World
    llo Wo
    ld
    However, I think I will leave it at this stage. The main thing I wanted to know was what those parenthesis were there for and now I have the answer. It did not really makes sense to group a pattern for -split operator hence I started this thread.
    I think that's all I wanted to know. Thank you.

  • Regular Expressions (Pattern/Matcher) --- Help

    Hi,
    I have an regex i.e. Pattern.compile("([0-9])D([0-9])'?(?:([0-9]+)\")?([NSEW])").{code}
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507
    According to the bug report, they have said that are many different regex that can trigger the stack overflow....even though the length of my input is not as long as the one posted on the bug report.
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I missed the '+' in my original regex Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])"){code}.
    I have also tried {code} Pattern.compile("(\\d+)D(\\d+)'?(?:(\\d+)\")?([NSEW])");And, the other 2 expressions as suggested by you.
    The problem happens when Durham Lat=”35D52’N” Lon=”78D47’W value is selected from a Jtree(the values are parsed from a xml file to the tree - the xml file has a bout 800 longitude/latitude elements for different cities in the US). It does not happen for other values and If I increment the degree or min by, then the expression works. I am not sure how else i could re-write this exp.
    Below is the snippet of the xml file:
    <State name="NORTH CAROLINA">
                <City name="Asheville AP"     Lat="35D26'N"     Lon="82D32'W"/>
                <City name="Charlotte AP"     Lat="35D13'N"     Lon="80D56'W"/>
                <City name="Durham"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Elizabeth City AP"     Lat="36D16'N"     Lon="76D11'W"/>
                <City name="Fayetteville, Pope AFB" Lat="35D10'N"     Lon="79D01'W"/>
                <City name="Goldsboro,Seymour-Johnson"     Lat="35D20'N"     Lon="77D58'W"/>
                <City name="Greensboro AP (S)"     Lat="36D05'N"     Lon="79D57'W"/>
                <City name="Greenville"     Lat="35D37'N"     Lon="77D25'W"/>
                <City name="Henderson"     Lat="36D22'N"     Lon="78D25'W"/>
                <City name="Hickory"     Lat="35D45'N"     Lon="81D23'W"/>
                <City name="Jacksonville"     Lat="34D50'N"     Lon="77D37'W"/>
                <City name="Lumberton"     Lat="34D37'N"     Lon="79D04'W"/>
                <City name="New Bern AP"     Lat="35D05'N"     Lon="77D03'W"/>
                <City name="Raleigh/Durham AP (S)"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Rocky Mount"     Lat="35D58'N"     Lon="77D48'W"/>
                <City name="Wilmington AP"     Lat="34D16'N"     Lon="77D55'W"/>
                <City name="Winston-Salem AP"     Lat="36D08'N"     Lon="80D13'W"/>
            </State>
    public final class GeoLine {
        /* Enum for the possible directions of longitude and latitude*/
        public enum Direction {
            N, S, E, W;
            public boolean isLongitude() {
                return (this == E || this == W);
            public boolean isLatitude() {
                return (this == N || this == S);
            public Direction getCanonicalDirection() {
                if (this == S) {
                    return Direction.N;
                } else if (this == W) {
                    return Direction.E;
                } else {
                    return this;
        private final int degree;
        private final int minute;
        private final int second;
        private final Direction dir;
        /* Recognizes longitude and latitude values that has degrees, minutes and seconds i.e. "45D15'34"N
        * or "45D1534"N. The single-quotes for the minutes is optional. And, for the moment we do not support seconds
        * validation although ilog library returns the longitude/latitude with second when NEs and Sub-networks are
        * dragged and dropped on the map.*/
    private static final Pattern PATTERN = Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])");
        public GeoLine(int degree, int minute, Direction dir) {
            this(degree, minute, 0, dir);
        public GeoLine(int degree, int minute, int second, Direction dir) {
            Log.logInfo(getClass().getSimpleName(), "PAU degree: " + degree + " minute: " + minute + " second: " + second + " direction: " +  dir);
            verifyLongitudeLatitude(degree, dir);
            verifyMinute(degree, minute, dir);   
            this.degree = degree;
            this.minute = minute;
            this.second = second;
            if (this.degree == 0 && this.minute == 0 && this.second == 0) {
                this.dir = dir.getCanonicalDirection();
            } else {
                this.dir = dir;
        public Direction getDirection() {
            return dir;
        public int getMinute() {
            return minute;
        public int getDegree() {
            return degree;
        public int getSecond() {
            return second;
        public static GeoLine parseLine(String location) {
            * Matcher class will throw java.lang.NullPointerException if a null location
            *  is passed, null location validation is not needed.
            Matcher m = PATTERN.matcher(location);
            if(m.matches()) {
                int deg;
                int min;
                int second;
                Direction direction;
                deg = Integer.parseInt(m.group(1));
                min = Integer.parseInt(m.group(2));
                if (m.group(3) == null) {
                    second = 0;
                } else {
                    second = Integer.parseInt(m.group(3));
                direction = Direction.valueOf(m.group(4));
                return new GeoLine(deg, min, second, direction);
            } else {
                throw new IllegalArgumentException("Invalid location value. Expected format XXDXX'XX\"[NSEW] " + location);
        private void verifyMinute(int deg, int min, Direction direction) {
            /* This validation is to make sure that minute does not exceed 0 if maximum value for latitude == 90
            * or longitude == 180 is specified */
            int maxDeg = direction.isLatitude() ? 90 : 180;
            if(min < 0 || min > 59) {
               throw new NumberFormatException("Minutes is out of range. Value should be less than 60: " + min);
            if (deg == maxDeg && min > 0) {
                throw new NumberFormatException("Degree value " + deg + "D" + direction + " cannot have minute exceeding 0: " + min);
        private void verifyLongitudeLatitude(int valDeg, Direction valDir) {
               int max = valDir.isLatitude() ? 90 : 180;
               if(valDeg < 0 || valDeg > max) {
                    throw new NumberFormatException("Degree " + valDeg + valDir + " is invalid");
        public final boolean isLongitude() {
            return dir.isLongitude();
        public final boolean isLatitude() {
            return dir.isLatitude();
        @Override
        public final String toString(){
            if(minute < 10){
                return degree + "D0" + minute + dir;
            } else {
                return degree + "D" + minute + dir;
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof GeoLine) {
                GeoLine other = (GeoLine) obj;          
                    return (this.degree == other.degree && this.minute == other.minute && this.second == other.second && this.dir == other.dir);
            return false;
        @Override
        public int hashCode() {
            int result = 17;
            result = result * 37 + degree;
            result = result * 37 + minute;
            result = result * 37 + second;
            result = result * 37 + dir.hashCode();
            return result;
    }Thank you again.

  • Regular Expression Pattern Question

    I'm building up a file URL String in my program. I'd like to remove all occurrences of "\\" in a String with "/" using the java.lang.String.replaceAll method:
    String fileName = "junk.txt";
    static String DEFAULT_FILE_URL_ROOT = "file:/" + System.getProperty("user.dir") + "/";
    String schemaLocation    = DEFAULT_FILE_URL_ROOT + fileName;
    schemaLocation.replaceAll(java.io.File.separator, "/");But when I run this, I get the following exception:
    java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
    ^
            at java.util.regex.Pattern.error(Pattern.java:1489)
            at java.util.regex.Pattern.compile(Pattern.java:1281)
            at java.util.regex.Pattern.<init>(Pattern.java:1030)
            at java.util.regex.Pattern.compile(Pattern.java:777)
            at java.lang.String.replaceAll(String.java:1710)
            at forum.jdom.example.DOMValidator.main(Unknown Source)What's the regex pattern I need to match "\\"? I can't find it. - MOD

    The file seperator is a string which represents the single character which is a backslash (in windows.)
    A single backslash in regex is an escape charater which escapes the next character. But there is no next character in your expression so it doesn't work. You need to replace what you have with the following...
    And if you really insist on using the constant then the expression would be...
    "\\" + java.io.File.separator

  • Regular Expression Pattern maching class to Validate Alphanumeric String

    Hi
    MY DB version is Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    I wanted to use the pattern maching classes given by oracle to check whether a given input string is alphanumeric or not.
    Oracle 10g documentation says about the classes like [:digit:], [:alnum:] and many others.
    http://www.dba-oracle.com/t_regular_expressions.htm
    However these classes seems not to be working with my DB version.
    Can someone tell me the DB version in which these classes works ?
    Below is the code I am using to validate a input string.
    SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
      2  (
      3     pi_value             IN       VARCHAR2
      4  )
      5  RETURN VARCHAR2
      6  IS
      7     lv_length   NUMBER;
      8  BEGIN
      9     lv_length := length(pi_value);
    10     IF ( REGEXP_LIKE(pi_value,'[:alnum:]{'||lv_length||'}')) THEN
    11        RETURN 'TRUE';
    12     ELSE
    13        RETURN 'FALSE';
    14     END IF;
    15  END fn_is_alphanumeric;
    16  /
    Function created.
    SQL>
    SQL>
    SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;
    ALPHA
    FALSE
    SQL>
    SQL>
    SQL> CREATE OR REPLACE FUNCTION fn_is_alphanumeric
      2  (
      3     pi_value             IN       VARCHAR2
      4  )
      5  RETURN VARCHAR2
      6  IS
      7     lv_length   NUMBER;
      8  BEGIN
      9     lv_length := length(pi_value);
    10     IF ( REGEXP_LIKE(pi_value,'[A-z0-9]{'||lv_length||'}')) THEN
    11        RETURN 'TRUE';
    12     ELSE
    13        RETURN 'FALSE';
    14     END IF;
    15  END fn_is_alphanumeric;
    16  /
    Function created.
    SQL> SELECT fn_is_alphanumeric('abc123') alpha FROM DUAL;
    ALPHA
    TRUE

    Character classes are working fine with regexp engine in your database version - simply change your function definition to:
    CREATE OR REPLACE FUNCTION fn_is_alphanumeric
       pi_value             IN       VARCHAR2
    RETURN VARCHAR2
    IS
       lv_length   NUMBER;
    BEGIN
       lv_length := length(pi_value);
       IF ( REGEXP_LIKE(pi_value,'[[:alnum:]]{'||lv_length||'}')) THEN
          RETURN 'TRUE';
       ELSE
          RETURN 'FALSE';
       END IF;
    END fn_is_alphanumeric;
    /(brackets should be doubled as compared with your original version).
    You can use both , range-based and class-based expressions, but you have to keep in mind, that range-based are nls dependant as opposite to class-based.
    SQL> alter session set nls_sort=binary;
    Session altered.
    SQL> with t as (
      2   select 'üäö123' s from dual
      3  )
      4  select
      5  case
      6  when regexp_like(s,'^[a-zA-Z0-9]+$') then 'Alphanumeric'
      7  else 'Not Alphanumeric'
      8  end range,
      9  case
    10  when regexp_like(s,'^[[:alnum:]]+$') then 'Alphanumeric'
    11  else 'Not Alphanumeric'
    12  end class
    13  from t
    14  /
    RANGE                CLASS
    Not Alphanumeric     Alphanumeric
    SQL>
    SQL> alter session set nls_sort='GERMAN';
    Session altered.
    SQL> with t as (
      2   select 'üäö123' s from dual
      3  )
      4  select
      5  case
      6  when regexp_like(s,'^[a-zA-Z0-9]+$') then 'Alphanumeric'
      7  else 'Not Alphanumeric'
      8  end range,
      9  case
    10  when regexp_like(s,'^[[:alnum:]]+$') then 'Alphanumeric'
    11  else 'Not Alphanumeric'
    12  end class
    13  from t
    14  /
    RANGE                CLASS
    Alphanumeric         AlphanumericBest regards
    Maxim

  • Regular expressions Pattern

    Hi
    I have to check for for some files in a file system if all the required files exists then next logic continues
    for ex: String pattern = "Hello(A|B|C|D|E|F|G).txt";
    for (int i =0; i < children.length; i++)
    if (Pattern.matches(pattern,children))
    set.add(children[i]);
    above code sets the elements to set if they exists but does't check if some file is missing.
    How do i check my condition for all matches, if not its should exit.
    any help whould be appreciated

    I think this is essentially the same as his other question.
    http://forum.java.sun.com/thread.jspa?threadID=709248

  • Regular Expressions (Pattern/Matcher)

    Hi,
    I have an regex i.e. *Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])").*
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507]
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance

    cienaP wrote:
    Hi,
    I have reposted the topic. Thank you for letting me know, this is my first time.You didn't need to create a [new thread|http://forums.sun.com/thread.jspa?threadID=5416548&messageID=10865976#10865976]! You could just have posted a response containing your regex. I shall lock this thread.

  • Unable to parse control character using regular expression & Pattern class

    I am trying to parse the Ctrl-X character from a string using the Pattern class but for some or the other reason it is not finding it.
    Here is the code that I wrote,
    Pattern p=Pattern.compile("\\cX");
    Matcher m=p.matcher(str);
    System.out.println(str+": "+m.find());
    the result is prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh : false
    where, str= prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh
    Thanks,
    Arunraj

    arunraj.nair wrote:
    I am trying to parse the Ctrl-X character from a string using the Pattern class but for some or the other reason it is not finding it.
    Here is the code that I wrote,
    Pattern p=Pattern.compile("\\cX");
    Matcher m=p.matcher(str);
    System.out.println(str+": "+m.find());
    the result is prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^Xh : false
    where, str= prop^Xau,bu,ca,en,fe,fi,ge,hj,ma,pe,re,sh,sr,tr^Yto^Xym^Yfmt^XhWhat does str.length() give you? And posting, and trying with, a (much) shorter String might help you and others here to more easily see the problem.
    db

  • Regular expression, Pattern.matcher() method

    Pattern.matcher() method start finding a new match from the end of the previous matcher.
    Can Pattern.matcher() method start finding a new match from the second letter of the previous match?
    For example, this piece of code will give a result as :
    find 1 --- 3
    find 4 --- 6
    +++++++++++++++++++++++++++++++++++++++++++++++++++
              Pattern pattern = Pattern.compile("aaa");
              Matcher matcher = pattern.matcher("aaaaaaa");
              while(matcher.find())
                   int from = matcher.start() + 1;
                   int to = matcher.end();
                   System.out.println("find " + from + " --- " + to);
    ++++++++++++++++++++++++++++++++++++++++++++++++++++
    How can I change the code so the programme can give a result as:
    find 1 --- 3
    find 2 --- 4
    find 3 --- 5
    find 4 --- 6
    find 5 --- 7
    Thanks very much in advance.

    Check out the API there are Two find methods
    public boolean find() - This method starts at the beginning of the input sequence or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character not matched by the previous match.
    public boolean find(int start) Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.
    so you could do it something like this:
    int startIndex = 0
    while (matcher.find(startIndex)){
      int from = matcher.start() + 1;
      int to = matcher.end();
      System.out.println("find " + from + " --- " + to);
      startIndex = ?????
    }

  • Regular expressions Pattern Matching

    Test Data
    1. xyz<<<testdata>>>123
    2. zzz<<<test<<<data>>>ssf
    3. sss<<<test<data>>>sffsd
    Expected Result
    1. <<<testdata>>>
    2. <<<data>>>
    2. <<<test<data>>>
    Sql Used:
    select REGEXP_SUBSTR('<<<testdata>>>', '(<<<)([^<<<]*)(>>>)', 1, 1) from dual;
    For 1 and 2 it gives me the proper value as expected, but for third test data its not giving any result.
    Can anyone please help me to get this result??

    how about this then:
    WITH t AS (SELECT 'Vendor <<<Acme Co>>>' col1
                 FROM dual
                UNION
               SELECT 'You PO Number <<<12345>>> has been generated.'
                 FROM dual
                UNION
               SELECT '<<<Wile e cyote>>>'
                 FROM dual
    SELECT t.col1
         , REGEXP_SUBSTR(t.col1, '[^a-zA-Z1-9\s]{3}(([a-zA-Z1-9]|\s)+)[^a-zA-Z1-9\s]{3}') new_col1
      FROM t
    COL1                                          NEW_COL1                                                                                                                                                                           
    <<<Wile e cyote>>>                            <<<Wile e cyote>>>                                                                                                                                                                  
    Vendor <<<Acme Co>>>                          <<<Acme Co>>>                                                                                                                                                                       
    You PO Number <<<12345>>> has been generated. <<<12345>>>                                                                                                                                                                         

  • Need a Regular Expression pattern in Java

    Hi,
        Thanks in advance for your help. I have to replace a string if it's not available inside any single quote.
       e.g.
                   name = 'abc12namexyz234' or name='def234namewsr345name' and name like '%ab123name345rt%'
          In the above I've to replace "name" with "ApplicantEntity.name" but I don't want to replace the string that is available inside the single quote i.e. 'abc12namexyz234'. The result after the replacement should be:
                   ApplicantEntity.name= 'abc12namexyz234' or ApplicantEntity.name='def234namewsr345name' and ApplicantEntity.name like '%ab123name345rt%'
         I am trying to find a appropriate regex. But still no success on that. Please Help....
    Thanks,
    Utpal

    .* matches with any character occuring 0 or more times (except newline characters)
    The problem is more likely to be that you really mean any character once or more times (any number of times include 0 times)
    To do this you need .+

  • Help in regular expression matching

    I have three expressions like
    1) [(y2009)(y2011)]
    2) [(y2008M5)(y2011M3)] or [(y2009M5)(y2010M12)]
    3) [(y2009M1d20)(y2011M12d31)]
    i want regular expression pattern for the above three expressions
    I am using :
    REGEXP_LIKE(timedomainexpression, '???[:digit:]{4}*[:digit:]{1,2}???[:digit:]{4}*[:digit:]{1,2}??', 'i');
    but its giving results for all above expressions while i want different expression for each.
    i hav used * after [:digit:]{4}, when i am using ? or . then its giving no results. Please help in this situation ASAP.
    Thanks

    I dont get your question Can you post your desired output? and also give some sample data.
    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Regular expressions with boolean connectives (AND, OR, NOT) in Java?

    I'd like to use regular expression patterns that are made up of simple regex patterns connected via AND, OR, or NOT operators, in order to do some keyword-style pattern matching.
    A pattern could look like this:
    (.*Is there.*) && (.*library.*) && !((.*badword.*) || (^$))
    Is there any Java regex library that allows these operators?
    I know that in principle these operators should be available, since Regular languages are closed under union, intersection, and complement.

    AND is implicit,
    xy -- means x AND yThat's not what I need, though, since this is just
    concatenation of a regex.
    Thus, /xy/ would not match the string "a y a x",
    because y precedes x.So it has to contain both x and y, but they could be
    in any order?
    You can't do that easily or generally.
    "x.*y|y.*x" wouldll work here, but obviously
    it will get ugly factorially fast as you add more
    terms.You got that right: AND means the regex operands can appear in any order.
    That's why I'm looking for some regex library that does all this ugly work for me. Again, from a theoretical point of view, it IS possible to express the described semantics of AND with regular expressions, although they will get rather obfuscated.
    Unless somebody has done something similar in java (e.g., for C++, there's Ragel: http://www.cs.queensu.ca/~thurston/ragel/) , I will probably use some finite-state-machine libraries and compile the complex regex's into automata (which can be minimized using well-defined operations on FSMs).
    >
    You'd probably just be better off doing multiple
    calls to matches() or whatever. Yes, that's another possibility, do the boolean operators in Java itself.
    Of course, if you
    really are just looking for literals, then you can
    just use str.contains(a) && !str.contains(b) &&
    (str.contains(c) || str.contains(d)). You don't
    seem to need regex--at least not from your example.OK, bad example, I do have "real" regexp's in there :)

  • How to define a regular expression using  regular expressions

    Hi,
    I am looking for some regular expression pattern which will identify a regular expression.
    Also, is it possible to know how does the compile method of Pattern class in java.util.regex package work when it is given a String containing a regex. ie. is there any mechanism to validate regular expression using regular expression pattern.
    Regards,
    Abhisek

    I am looking for some regular expression pattern which will identify a regular
    expression. Also, is it possible to know how does the compile method of
    Pattern class in java.util.regex package work when it is given a String
    containing a regex. ie. is there any mechanism to validate regular
    expression using regular expression pattern.It is impossble to recognize an (in)valid regular expression string using a
    regular expression. Google for 'pumping lemma' for a formal proof.
    kind regards,
    Jos

Maybe you are looking for

  • Update 100 Row Data In One Time against a Code

    Dear Expert, How can I update a Master Data Row Table record using a particular code. Like I write a query Update Table Set U_UDF = 'Value' Where Code = 2 U_UDF is the field of Master Data Row Table's field. There are 100 Row against code 2 & I want

  • Why is the screen of my iphone 4 has no light

    Hi There, I have and Iphone 4 and, I was finish a call when the screen become black like it showted down and sence then I can turn it on again and I know wverything is working well bit sence the screen is black I can't see anything! Please help me to

  • Should I use Java?

    Hi all, I have a little VB6 experience, but I dont really know much about coding. I want to design a desktop application, you can almost call it payroll software, not big, just something basic to manage a few workers. Can I use Java for this purpose?

  • Executing one system command from one java class. ERROR. Please help me

    Hello i am trying to add users into one linux machine using one jaav program but when i execute the java class the system doesn't show me any error and dont make anything. The linux command, in the main of the class, is correct; from thelinux shell i

  • Conversion of .vox files into .wav file format

    hi guys, can anyone tell how to write a program to convert .vox media files to .wav files using JMF or anything in java