Meaning of given regular expression

Hi all,
I want to know how the regular expression in following query works.
SELECT UNIQUE REGEXP_REPLACE (catalog_url, 'http:// (\[ ^ / \] + ) . * ', '\1')
FROM oe.product_information ;
Here I put spaces for ease of understanding.
soni
Edited by: sonidba on Feb 5, 2010 12:28 PM
Edited by: sonidba on Feb 5, 2010 12:30 PM

Hi,
\n is actually backreference expression.
In your query,
With tab AS(
SELECT 'http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions130.htm#i1305521' catalog_url FROM dual
SELECT UNIQUE REGEXP_REPLACE(catalog_url, 'http://([^/]+).*','\1')
FROM tab ;It means that, whatever was matched between the first set of parentheses, which is
([^/]+)return that. So, on executing this query, you will get this
download.oracle.comThanks,
Ankur

Similar Messages

  • 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.

  • Please  deocode the given Regular Expression ^[A-Za-z0-9\&\'\(\)\-\.\"\\s]*

    Hi,
    Please deocode the given (RE)Regular Expression ^[A-Za-z0-9\&\'\(\)\-\.\"\\s]* ,and so that i can use this RE in the validation.xml of STRUTS for the inbuilt "mask" validator of validator-rules.xml.
    Thanks and Regards,
    Manish Jain.

    You want to know what it does?
    For starters there is an error. The '\\s' at the end is non-sensical. The '\\' escapes to a '\' and thus has no impact on the 's'. And the 's' is already in the range of 'a-z' so I am guessing it should actually be '\s'.
    The regex says that it will find zero or more characters in the specified range starting at the beginning of the string.
    The character range is...
    A-Z
    a-z
    0-9
    <any whitespace character>

  • Help regarding regular expression

    HI All ,
    Please see the following string
    String s = "IF ((NOT NUM4 IS ALPHABETIC ) AND NUM3 IS ALPHABETIC-UPPER AND (NUM5 IS GREATER OR EQUAL TO 3) AND (NUM5 IS NOT GREATER THAN 3) AND (NUM3 GREATER THAN 46) AND (NUM5 GREATER THAN NUM3) OR NUM3 LESS THAN 78) .";
    My problem is: i want to capture the part of this line which contains "ALPHABETIC ,ALPHABETIC-UPPER for ex :NOT NUM4 IS ALPHABETIC , NUM3 IS ALPHABETIC-UPPER.from that I have to capture the word num4 , num3 which are in these phrases only ;from the whole string whereever it exists along with the phrase,Can any one help me out by suggesting something.num4 and num3 are variable names

    I suspect you're right, Sabre, but I can't resist...
    import java.util.regex.*;
    * A rewriter does a global substitution in the strings passed to its
    * 'rewrite' method. It uses the pattern supplied to its constructor, and is
    * like 'String.replaceAll' except for the fact that its replacement strings
    * are generated by invoking a method you write, rather than from another
    * string. This class is supposed to be equivalent to Ruby's 'gsub' when given
    * a block. This is the nicest syntax I've managed to come up with in Java so
    * far. It's not too bad, and might actually be preferable if you want to do
    * the same rewriting to a number of strings in the same method or class. See
    * the example 'main' for a sample of how to use this class.
    * @author Elliott Hughes
    public abstract class Rewriter
      private Pattern pattern;
      private Matcher matcher;
       * Constructs a rewriter using the given regular expression; the syntax is
       * the same as for 'Pattern.compile'.
      public Rewriter(String regularExpression)
        this.pattern = Pattern.compile(regularExpression);
       * Returns the input subsequence captured by the given group during the
       * previous match operation.
      public String group(int i)
        return matcher.group(i);
       * Overridden to compute a replacement for each match. Use the method
       * 'group' to access the captured groups.
      public abstract String replacement();
       * Returns the result of rewriting 'original' by invoking the method
       * 'replacement' for each match of the regular expression supplied to the
       * constructor.
      public String rewrite(CharSequence original)
        this.matcher = pattern.matcher(original);
        StringBuffer result = new StringBuffer(original.length());
        while (matcher.find())
          matcher.appendReplacement(result, "");
          result.append(replacement());
        matcher.appendTail(result);
        return result.toString();
      public static void main(String[] args)
        String s = "IF ((NOT NUM4 IS ALPHABETIC ) " +
                    "AND NUM3 IS ALPHABETIC-UPPER " +
                    "AND (NUM5 IS GREATER  OR EQUAL TO 3) " +
                    "AND (NUM5 IS NOT GREATER THAN 3) " +
                    "AND (NUM3 GREATER THAN 46) " +
                    "AND NUM645 IS ALPHABETIC " +
                    "AND (NUM5 GREATER THAN NUM3) " +
                    "OR NUM3 LESS THAN 78 " +
                    "AND NUM34 IS ALPHABETIC-UPPER " +
                    "AND NUM92 IS ALPHABETIC-LOWER " +
                    "AND NUM0987 IS ALPHABETIC-LOWER) .";
        String result =
          new Rewriter("(NUM\\d+) +IS +(ALPHABETIC(?:-(?:UPPER|LOWER))?)")
            public String replacement()
              String type = group(2);
              if (type.endsWith("UPPER"))
                return "Character.isUpper(" + group(1) + ")";
              else if (type.endsWith("LOWER"))
                return "Character.isLower(" + group(1) + ")";
              else
                return "Character.isLetter(" + group(1) + ")";
          }.rewrite(s);
        System.out.println(result);
    }

  • Regular expression - variable

    I need to add a piece of code in each page in a directory with some info that is specific to that directory.  There are several hundred directories and about 10,000 pages.  My plan was to search and replace all files in each directory one at a time.  Then I remembered RegEx and thought there may be a better solution.
    The code I want to build off of looks like this:
    <?php
    setcookie("capital", "boston", time()+31536000, "/");
    ?>
    The only variable part is the the city name (i.e. boston could be denver, tampa, miami, etc.).  This bit of text will always be a word with only letters and no spaces.I'd like to search for this code, using regular expressions to capture the variable (i.e "boston"), then replace it with the exact same code, plus add another snippet using the stored variable.
    The end result should look like this:
    <?php
    setcookie("capital", "boston", time()+31536000, "/");
    $urlcookievariable = "boston";
    ?>
    My RegEx attempt looks like this:
    SEARCH:
    <?php
    setcookie("capital", "[^"]*", time()+31536000, "/");
    ?>
    REPLACE:
    <?php
    setcookie("capital", "[^"]*", time()+31536000, "/");
    $urlcookievariable = "$1";
    ?>
    However, it's not seeming to find the original line of code.  Since my search is working, my replace is obviously not working either.  However, with some testing on a more simple line of regex, that variable is not pasting as a variable.  It's just putting the literal symbol:  dollar sign and #1....$1, not "boston"
    thanks in advance for a point in the right direction

    The problem with your regex is that the original code includes metacharacters that have special meaning in a regular expression. Use this as the search value:
    (setcookie\("capital", ("[^"]+"), time\(\)\+31536000, "\/"\);)
    Use this as the Replace value:
    $1\n$urlcookievariable = $2;

  • Trouble with tribbles, i mean regular expressions

    Hi all
    im trying to make a regular expression that finds all the comments in a given string
    stuff like this
    /* this is my comment */
    then what i want to do is to remove all those found comments from the string and leave me with the original string without any comments.
    anyway i know i need a pattern but i cant get my pattern right, this is what i have at the moment
    Pattern remComment = Pattern.compile(" ^\\*?[\\w\\s\\W]+?*\\ ", Pattern.DOTALL | Pattern.MULTILINE);
    can anyone help me and let me know where im going wrong
    im basically trying to say any thing that starts with \* <any other text here> until a *\
    thanks

    There is something else wrong, I just tryied:
    * Comments.java
    * version 1.0
    * 07/06/2005
    package samples;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    * @author notivago
    public class Comments {
         * @param args
        public static void main(String[] args) {
            String comment =
                "/*\r\n" +
                "does this do it won\r\n" +
                "*/\r\n" +
                ".activegrouptab\r\n" +
                "{\r\n" +
                "white-space:nowrap;\r\n" +
                "border-top-width:1pt;\r\n" +
                "cursor:hand;\r\n" +
                "}\r\n" +
                "/*\r\n" +
                "does this do it too\r\n" +
                "*/\r\n" +
                ".activegrouptabdisabled\r\n" +
                "{\r\n" +
                "font-family:verdana;\r\n" +
                "font-size:7pt;\r\n" +
                "}\r\n" +
                "/*\r\n" +
                "does this do it free\r\n" +
                "*/\r\n" +
                ".activesectiontab\r\n" +
                "{\r\n" +
                "width:90%;\r\n" +
                "background-image:url(hocbt.gif);\r\n" +
                "overflow:auto;\r\n" +
                "color:#ffffff;\r\n" +
            Pattern remComment = Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL | Pattern.MULTILINE);
            Matcher matcher = remComment.matcher(comment);
            while( matcher.find() ) {            
                System.out.println( "The comment: \n" + matcher.group() );
                System.out.println("----");
    }with the output:
    The comment:
    does this do it won
    The comment:
    does this do it too
    The comment:
    does this do it free
    ----

  • Getting the regular expression from the given text

    Hi
    I need to develope an application which can convert the given text into the regular expression. I need that when i enter any text in textarea that should be translated into regular expression in another panel. but i could not find the method or technique which can do so. plz help me to resolve this issue.
    Thanks Imran khan.

    well, there are an infinite number of regular expressions for an arbitrary piece of text, so you will have to qualify in your mind what the purpose of the regular expression is.
    For instance, it is trivial to create a regex for a string just by copying the input text, and inserting \ before any special characters. But this pattern would probably be quite silly.

  • Meaning of regular expression in detail

    Hi All,
    I am not sure whether this question is in correct forum type but my question is
    what is detail meaning following regular expression ?Please help me to understand this character by character.
    Expression is ^[\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Z]{2,4}$
    Thanks,

    sabre150 wrote:
    In general terms, that regular expression is a very poor attempt to check an email address syntax. Very poor because it does not cover the full specification.Yes. And following on from that: if your application looks at somebody's (valid) e-mail address and tells them it isn't a valid e-mail address, they are going to think you are a fool. And if your application is being used for commercial purposes, that would be a black mark against your company. You're better off not validating e-mail addresses at all than implementing a solution with false negatives.

  • How to create a list of string if a regular expression is given ?

    Hi folks,
    I have a regular expression say abcd[a-z]\\\.[0-9] . ( please ignore one '\')
    For this string i know that
    following string matches successfully
    1. abca.0
    2. abcb.1
    3. abcz.9 ......etc n number of combination are possible.
    is there any algorithm which will create some randomn strings from a regular expression.
    input to algorithm : some string pattern
    output to algorithm : some matching strings ( can be a single or an array of matching strings)
    Thanks in advance..
    Sethu
    Edited by: Sethumadhavan on Apr 16, 2008 6:32 AM

    Can u please give little more explanation...
    If i get some some values i can exit with the values ... and from the values i got i can ignore the duplicates ...
    But i am not getting the basic algorithm to get list of strings.....( DFA? or NFA?)
    thanks
    sethu

  • Re: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't forget about the regular expression potential

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

    Namburi,
    When you said you used the Reg Exp tool, did you use it only as
    preconfigured by the iMT migrate application wizard?
    Because the default configuration of the regular expression tool will only
    target the files in your ND project directories. If you wish to target
    classes outside of the normal directory scope, you have to either modify the
    "Source Directory" property OR create another instance of the regular
    expression tool. See the "Tool" menu in the iMT to create additional tool
    instances which can each be configured to target different sets of files
    using different sets of rules.
    Usually, I utilize 3 different sets of rules files on a given migration:
    spider2jato.xml
    these are the generic conversion rules (but includes the optimized rules for
    ViewBean and Model based code, i.e. these rules do not utilize the
    RequestManager since it is not needed for code running inside the ViewBean
    or Model classes)
    I run these rules against all files.
    See the file download section of this forum for periodic updates to these
    rules.
    nonProjectFileRules.xml
    these include rules that add the necessary
    RequestManager.getRequestContext(). etc prefixes to many of the common
    calls.
    I run these rules against user module and any other classes that do not are
    not ModuleServlet, ContainerView, or Model classes.
    appXRules.xml
    these rules include application specific changes that I discover while
    working on the project. A common thing here is changing import statements
    (since the migration tool moves ND project code into different jato
    packaging structure, you sometime need to adjust imports in non-project
    classes that previously imported ND project specific packages)
    So you see, you are not limited to one set of rules at all. Just be careful
    to keep track of your backups (the regexp tool provides several options in
    its Expert Properties related to back up strategies).
    ----- Original Message -----
    From: <vnamboori@y...>
    Sent: Wednesday, August 08, 2001 6:08 AM
    Subject: [iPlanet-JATO] Re: Use Of models in utility classes - Pease don't
    forget about the regular expression potential
    Thanks Matt, Mike, Todd
    This is a great input for our migration. Though we used the existing
    Regular Expression Mapping tool, we did not change this to meet our
    own needs as mentioned by Mike.
    We would certainly incorporate this to ease our migration.
    Namburi
    --- In iPlanet-JATO@y..., "Todd Fast" <toddwork@c...> wrote:
    All--
    Great response. By the way, the Regular Expression Tool uses thePerl5 RE
    syntax as implemented by Apache OROMatcher. If you're doing lotsof these
    sorts of migration changes manually, you should definitely buy theO'Reilly
    book "Mastering Regular Expressions" and generate some rules toautomate the
    conversion. Although they are definitely confusing at first,regular
    expressions are fairly easy to understand with some documentation,and are
    superbly effective at tackling this kind of migration task.
    Todd
    ----- Original Message -----
    From: "Mike Frisino" <Michael.Frisino@S...>
    Sent: Tuesday, August 07, 2001 5:20 PM
    Subject: Re: [iPlanet-JATO] Use Of models in utility classes -Pease don't
    forget about the regular expression potential
    Also, (and Matt's document may mention this)
    Please bear in mind that this statement is not totally correct:
    Since the migration tool does not do much of conversion for
    these
    utilities we have to do manually.Remember, the iMT is a SUITE of tools. There is the extractiontool, and
    the translation tool, and the regular expression tool, and severalother
    smaller tools (like the jar and compilation tools). It is correctto state
    that the extraction and translation tools only significantlyconvert the
    primary ND project objects (the pages, the data objects, and theproject
    classes). The extraction and translation tools do minimumtranslation of the
    User Module objects (i.e. they repackage the user module classes inthe new
    jato module packages). It is correct that for all other utilityclasses
    which are not formally part of the ND project, the extraction and
    translation tools do not perform any migration.
    However, the regular expression tool can "migrate" any arbitrary
    file
    (utility classes etc) to the degree that the regular expressionrules
    correlate to the code present in the arbitrary file. So first andforemost,
    if you have alot of spider code in your non-project classes youshould
    consider using the regular expression tool and if warranted adding
    additional rules to reduce the amount of manual adjustments thatneed to be
    made. I can stress this enough. We can even help you write theregular
    expression rules if you simply identify the code pattern you wish to
    convert. Just because there is not already a regular expressionrule to
    match your need does not mean it can't be written. We have notnearly
    exhausted the possibilities.
    For example if you say, we need to convert
    CSpider.getDataObject("X");
    To
    RequestManager.getRequestContext().getModelManager().getModel(XModel.class);
    Maybe we or somebody else in the list can help write that regularexpression if it has not already been written. For instance in thelast
    updated spider2jato.xml file there is already aCSpider.getCommonPage("X")
    rule:
    <!--getPage to getViewBean-->
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getPage[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getViewBean($1ViewBean.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    Following this example a getDataObject to getModel would look
    like this:
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[CSpider[.\s]*getDataObject[\s]*\(\"([^"]*)\"]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[getModel($1Model.class]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    In fact, one migration developer already wrote that rule andsubmitted it
    for inclusion in the basic set. I will post another upgrade to thebasic
    regular expression rule set, look for a "file uploaded" posting.Also,
    please consider contributing any additional generic rules that youhave
    written for inclusion in the basic set.
    Please not, that in some cases (Utility classes in particular)
    the rule
    application may be more effective as TWO sequention rules ratherthan one
    monolithic rule. Again using the example above, it will convert
    CSpider.getDataObject("Foo");
    To
    getModel(FooModel.class);
    Now that is the most effective conversion for that code if that
    code is in
    a page or data object class file. But if that code is in a Utilityclass you
    really want:
    >
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    So to go from
    getModel(FooModel.class);
    To
    RequestManager.getRequestContext().getModelManager().getModel(FooModel.class
    You would apply a second rule AND you would ONLY run this rule
    against
    your utility classes so that you would not otherwise affect yourViewBean
    and Model classes which are completely fine with the simplegetModel call.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getModel\(]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getModel\(]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getRequestContext().getModelManager().getModel(]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    A similer rule can be applied to getSession and other CSpider APIcalls.
    For instance here is the rule for converting getSession calls toleverage
    the RequestManager.
    <mapping-rule>
    <mapping-rule-primarymatch>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-primarymatch>
    <mapping-rule-replacement>
    <mapping-rule-match>
    <![CDATA[getSession\(\)\.]]>
    </mapping-rule-match>
    <mapping-rule-substitute>
    <![CDATA[RequestManager.getSession().]]>
    </mapping-rule-substitute>
    </mapping-rule-replacement>
    </mapping-rule>
    ----- Original Message -----
    From: "Matthew Stevens" <matthew.stevens@e...>
    Sent: Tuesday, August 07, 2001 12:56 PM
    Subject: RE: [iPlanet-JATO] Use Of models in utility classes
    Namburi,
    I will post a document to the group site this evening which has
    the
    details
    on various tactics of migrating these type of utilities.
    Essentially,
    you
    either need to convert these utilities to Models themselves or
    keep the
    utilities as is and simply use the
    RequestManager.getRequestContext.getModelManager().getModel()
    to statically access Models.
    For CSpSelect.executeImmediate() I have an example of customhelper
    method
    as a replacement whicch uses JDBC results instead of
    CSpDBResult.
    matt
    -----Original Message-----
    From: vnamboori@y... [mailto:<a href="/group/SunONE-JATO/post?protectID=081071113213093190112061186248100208071048">vnamboori@y...</a>]
    Sent: Tuesday, August 07, 2001 3:24 PM
    Subject: [iPlanet-JATO] Use Of models in utility classes
    Hi All,
    In the present ND project we have lots of utility classes.
    These
    classes in diffrent directory. Not part of nd pages.
    In these classes we access the dataobjects and do themanipulations.
    So we access dataobjects directly like
    CSpider.getDataObject("do....");
    and then execute it.
    Since the migration tool does not do much of conversion forthese
    utilities we have to do manually.
    My question is Can we access the the models in the postmigration
    sameway or do we need requestContext?
    We have lots of utility classes which are DataObjectintensive. Can
    someone suggest a better way to migrate this kind of code.
    Thanks
    Namburi
    [email protected]
    [email protected]
    [Non-text portions of this message have been removed]
    [email protected]
    [email protected]

  • Evaluate Regular expression complexity

    Hi all
    I've a problem on regular expression usage in my application.
    I'm using a regular expression to identify objects and fetch them to be served depending on an input string with has to be matched.
    each object has a property representing a regular expression to be matched to be candidate for fetching.
    my program receive an external input string, then loops on the full objects collection identifying which are the object whose regular expression match the input stream.
    doing an example:
    obj1) key = "J*SDK"
    obj2) key = "Ja*6*"
    obj3) key = "JEE*"
    if the input string is "Java 6.0 SDK" obj1 and obj2 are cadidate, while obj3 is discarded.
    up to now everithing is fine, now here is my question:
    i want only one object as output and I want the one best matching my input string.
    this means that
    -> obj1 is matching 4 chatacter ans has only one wildchar
    -> obj2 is matching 3 characters and has two wildcard
    so obj2 is discarded since it's regular expression is more complex than the obj1 one
    my problem is HOW to evaulate correctly such complexity for each candidate object to be able to choose my best object.
    is there some formal rule / api for this?
    I'd like to match all wildcards into the regex, but doing this "by hand" would surely result in some bug due to some missing case, so a "third party" API or a grammar rule would be useful.
    hoping for you help.
    regards
    Michele Sacchetti

    ok, after days and days of research i came up to this solution:
    1) I used this (http://www.brics.dk/automaton) package for regular expression which let me access the internal state automa data
    2) use the getShortestExample() method to retrieve the shortest string matching the given regExp
    3) evaluate the Levenshtein Distance between the given string and the one to be matched
    PROs:
    1) the regexp logic is fully handled by the same state machine which take cares of pattern matching in the first phase
    2) the library provide me a non-regexp string to be used with comparison (e.g Levenshtein Distance evaluation)
    CONs:
    1) the methods getShortestExample is unaware of string to be matched, so if i use "aab|aaa" to match "aab" the method gets the first shortest sort alfabetically, that is "aaa", so I get a LD of 1 even if it should be 0, but it's quite a good deal for my application.
    @endasil : your solution rely on grouping, and is based on a pre-parsing done manually so it basically went back to the "manual" parsing i wanted to avoid
    Another way I'd like to give a try but had to give up was to use ANTLR (www.antlr.org) to create a parser for regular expression and then evaluating the resulting "tree size" of the parser, but wasn't able to find a formal description of RegExp grammar on the net.
    do you have any suggestion or comment on my solution (or other to give a try? )

  • Dumbfounded by Scanner processing String using regular expression

    I was reading Bruce Eckel's book when I came across something interesting: extending Scanner with regular expressions. Unfortunately, I was confronted with an issue that doesn't make much sense to me: if the String that I am scanning contains a hyphen, the Scanner doesn't produce anything. As soon as I take it out, it all works like a charm. Here is my example:
    import java.util.Scanner;
    import java.util.regex.*;
    public class StringScan {
    public static void main (String [] args){
         String input = "there's one caveat when scanning with regular expressions";
         Scanner scanner = new Scanner (input);
         String pattern = "[a-z]\\w+";
         while (scanner.hasNext(pattern)){
              scanner.next(pattern);
              MatchResult match = scanner.match();
              String output = match.group();
              System.out.println(output);
    }What could be the reason? I imagined it could be because the hyphen for some reason gets given a special meaning but when I tried escaping it, it still didn't work.

    Thanks for your prompt reply.
    I have figured out what was wrong with my code, by the way. Since a single quote is not a word character, it does not match w+. And as the very first input token does not match, the scanner stops immediately. I rewrote my regex to "[a-z].*" and now it does work.

  • Range & Regular Expression issue.

    I'm having a bit of trouble and I'm close to head butting a wall. It's a logic problem. I am trying to create a class, when given a range e.g., 52 - 234 it will output the regular expression
    [5][2-9] | [6-9][0-9] | [1][0-9][0-9] | [2][0-2][0-9] | [2][3][0-4]
    another example
    12-23
    [1][2-9] | [2][0-3]
    It's giving me a logic headache. I can't help but walk around thinking in for loops after trying to get this to work. However, I noticed that someone on the Internet has made a Java tool that does exactly this, but all their links are dead :o(
    Anyone got any ideas? Seen this before? Done this yourself? Help? I've been at this for days now, and I'm fed up!
    Thanks :o)

    Two things:
    1. To use quote inside quoted string you must put two quotes in a row.
    2. Certain characters have special meaning in regeular expressions. You must escape them with \ if you do not want regexp to interpret such characters.
    Select regexp_replace('kathu&+','[/.#''& "\\-\+]')from dual;
    REGEX
    kathu
    SQL>
    {code}
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Regular Expression Technique in ColdFusion

    I'm new to Coldfusion and I've never really used regular expressions before.  How would I write a ColdFusion function (or just a conditional statement) to check if a form variable is a match for an IP network (44.42.94.0/18)?
    I'm just basically looking to see if the backslash "/" character is in the string.

    There are actually plenty of well-developed regular expression strings available on the Internet, which you can simply "copy and use."  You don't have to spend too much time figuring-out the correct pattern of chicken scratches.
    It's not quite as convenient as saying  "use Regexp::Common::URL;" but one cannot have everything in "less-enlightened" languages like CF...
    You do need to understand them, however.  When you look at the string given in a previous reply, you do need to understand the meaning of all those symbols, and you need to practice the art of being able to cook them up extemporaneously.

  • Logical AND in Java Regular Expressions

    I'm trying to implement logical AND using Java Regular Expressions.
    I couldn't figure out how to do it after reading Java docs and textbooks. I can do something like "abc.*def", which means that I'm looking for strings which have "abc", then anything, then "def", but it is not "pure" logical AND - I will not find "def.*abc" this way.
    Any ideas, how to do it ?
    Baken

    First off, looks like you're really talking about an "OR", not an "AND" - you want it to match abc.*def OR def.*abc right? If you tried to match abc.*def AND def.*abc nothing would ever match that, as no string can begin with both "abc" and "def", just like no numeric value can be both 2 and 5.
    Anyway, maybe regex isn't the right tool for this job. Can you not simply programmatically match it yourself using String methods? You want it to match if the string "starts with" abc and "ends with" def, or vice-versa. Just write some simple code.

Maybe you are looking for

  • Vixia HF10 no longer recognized by iMac

    I've had my Canon HF10 for about a year now and I used to be able to connect it via usb and iMovie would automatically open and I could import my HD movies. I haven't touched the HF10 since at least Thanksgiving '08 and decided to load the movies int

  • My two iPads share an Apple ID.  How can I create a separate Game Center account so they can play each other?

    My two iPads share an Apple ID.  How can I create a separate Game Center account so they can play each other?

  • Where can I see my store credit?

    I was given ap store credit as a birthday gift some time ago, I know it isn't finished, but I want to know how much I have left before I decide what to buy, and I only ever remember seeing the residue after making a purchase. Reasonably there should

  • Installing 32-bit alongside 64-bit

    I have the 64-bit drivers installed successfully on my 64-bit Windows 7 system, and they work correctly. I need to install the 32-bit drivers as well, but I haven't been able to make them work yet. When I open the 32-bit ODBC Data Source Administrato

  • Foreign language format problem

    Hi, I have a glossary of Tibetan words that was made in MS Excel using a form of transliteration in Latin characters, and now I want to update it using Tibetan fonts, which I use in Pages. So long as I am clicked in the cell, the word displays correc