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.

Similar Messages

  • Using regular expressions

    Hi Experts,
    After going through some documentation on regular expressions in Oracle I have tried to draw some conclusions about the same. As I wasn’t much confident on how the patterns are built, I have tried to interpret them by looking at the output. It’s basically a reverse engineering I have tried to do.
    Please let me know if my interpretations are correct. Any additions /suggestions/corrections are most welcome.
    Some of the examples may lack conclusions, please ignore those.
    select regexp_substr('1PSN/231_3253/ABc','^([[:alnum:]]*)') from dual;
    Output: 1PSN
    Interpreted as:
    ^ From the start of the source string
    ([[:alnum:]]*) zero or more occurrences of alphanumeric characters
    select regexp_substr('@@/231_3253/ABc','@*([[:alnum:]]+)') from dual;
    Output: 231
    Interpreted as:
    @* Search for zero or more occurrences of @
    ([[:alnum:]]+) followed by one or more occurrences of alphanumeric characters
    Note: In the above example oracle looks for @(zero times or more) immediately followed by alphanumeric characters.
    Since a '/' comes between @ and 231 the o/p is 0 occurences of @ + one or more occurrences of alphanumerics.
    select regexp_substr('1@/231_3253/ABc','@+([[:alnum:]]*)') from dual;
    Output: @
    Interpreted as:
    @+ one or more ocurrences of @
    ([[:alnum:]]*) followed by 0 or more occurrences of alphanumerics
    select regexp_substr('1@/231_3253/ABc','@+([[:alnum:]]+)') from dual;
    Output: Null
    Interpreted as:
    @+ one or more occurences of @
    ([[:alnum:]]+) followed by one or more occurences of aplhanumerics
    select regexp_substr('@1PSN/231_3253/ABc125','([[:digit:]]+)$') from dual;
    Output: 125
    Interpreted as:
    ([[:digit:]]+) one or more occurences of digits only
    $ at the end of the string
    select regexp_substr('@1PSN/231_3253/ABc','([^[:digit:]]+)$') from dual;
    output: /ABc
    Interpreted as:
    ([^[:digit:]]+)$ one or more occurrences of non-digit literals at the end of the string
    '^' inside square brackets marks the negation of the class
    Look for http:// followed by a substring of one or more alphanumeric characters and optionally, a period (.)
    SELECT REGEXP_SUBSTR('Go to http://www.oracle.com/products and click on database','http://([[:alnum:]]+\.?){3,4}/?') RESULT
    FROM dual;
    Output: http://www.oracle.com
    Interpreted as:
    [[:alnum:]]+ one or more occurences of alplanumeric characters
    \.? dot optionally (backslash represents escape sequence,? represents optionally)
    {3,4} 3 or 4 times
    /? followed by forward slash optionally
    If you have www.oracle.co.uk; {3,4} extracts it for you as well
    Validate email:
    select case  when
           REGEXP_LIKE('[email protected]',
                       '^([[:alnum:]]+(\_?|\.))([[:alnum:]]*)@([[:alnum:]]+)(.([[:alnum:]]+)){1,2}$') then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Interpreted as:
    ([[:alnum:]]+(\_?|\.)) one or more occurrences of alpha numerics optionally followed by an underscore or dot
    ([[:alnum:]]*) followed by 0 or more occurrences of alplhanumerics
    @ followed by @
    ([[:alnum:]]+) followed by one or more occurrences of alplhanumerics
    (.([[:alnum:]]+)){1,2} followed by a dot followed by alphanumerics from once till max of twice (Ex- .com or .co.uk)
    Output: Match Found
    Input: [email protected]
    Output: Match Found
    Input: [email protected]
    Output: No Match Found
    Truncate the part, ending with digits
    select regexp_substr('Yahoo11245@US','^.*[[:digit:]]',1) from dual;
    Output: Yahoo11245
    select regexp_substr('*Yahoo*11245@US','^.*[[:digit:]]',1) from dual;
    Output: *Yahoo*11245
    Interpreted as:
    .* zero or more occurrences of any characters (dot signifies any character)
    Replace 2 to 8 spaces with single space
    select regexp_replace('Hello   you      OPs       there','[[:space:]]{2,8}',' ')
    from dual;
    Search for control characters
    select case  when
           regexp_like('Super' || chr(13) || 'Star' ,'[[:cntrl:]]')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Output: Match Found
    Search for lower case letters only with a string length varying from a min of 3 to max of 12
    select case  when
           regexp_like('terminator' ,'^[[:lower:]]{3,12}$')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    4th character must be a special character
    select case  when
           regexp_like('ter*minator' ,'^...[^[:alnum:]]')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Ouput: Match Found
    Case Sensitive Search
    select case  when
           regexp_like('Republic Of  Africa' ,'of','c')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Output: No match found
    c stands for case sensitive
    select case  when
           regexp_like('Republic Of  africa' ,'of','i')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Output: Match Found
    i stands for case insensitive
    Two consecutive occurences of characters from a to z
    select regexp_substr('Republicc Of Africaa' ,'([a-z])\1', 1,1,'i') from dual;
    Output: cc
    Interpreted as:
    ([a-z]) character set a-z
    \1 consecutive occurence of any character
    1 starting from 1st character in the string
    1 First occurence
    i case insensitive
    Three consecutive occurences of characters from 6 to 9
    select case  when
           regexp_like('Patch 10888 applied' ,'([7-9])\1\1')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Output: Match Found
    Phone validator:
    select case  when
           regexp_like('123-44-5555' ,'^[0-9]{3}-[0-9]{2}-[0-9]{4}$')
                  then 'Match Found'
           else 'No Match Found'
           end
    as output from dual;
    Output: Match Found
    Input: 111-222-3333
    Output: No match found
    Interpreted as:
    ^ start of the string
    [0-9]{3} three ocurrences of digits from 0-9
    - followed by hyphen
    [0-9]{2} two ocurrences of digits from 0-9
    - followed by hyphen
    [0-9]{4} four ocurrences of digits from 0-9
    $ end of the string
    ************************************************************************Source Links:
    http://www.psoug.org/reference/regexp.html
    http://www.oracle.com/technology/obe/obe10gdb/develop/regexp/regexp.htm
    Edited by: Preta on Feb 25, 2010 4:38 PM
    Corrected the example for www.oracle.com
    Edited by: Preta Incorported Logan's comments

    Hi,
    It looks like you have a good understanding of how regular expressions work.
    You can put comments like the ones in your message directly in the code. For example, your validate e-mail code could be re-written
    select      case 
             when REGEXP_LIKE ( '[email protected]'
                        , '^'          || -- Starting from the beginning of the string
                        '('          || -- Begin \1
                          '[[:alnum:]]+'|| --     0 or more alphnumerics
                          '(\_?|\.)'     || --     optional underscore or dot
                        ')'          || -- End \1
                        '([[:alnum:]]*)'|| -- 0 or more alphnumerics
                        '@'          || -- @ sign
                        '([[:alnum:]]+)'|| -- 1 or more alpanumerics
                        '('          || -- Begin \5
                          '\.'          || --   dot
                          '([[:alnum:]]+)'
                                  || --   1 or more alphanumerics
                        ')'          || -- End \5
                        '{1,2}'          || -- \5 can occur 1 or 2 times
                        '$'             -- End of string
             then 'Match Found'
                    else 'No Match Found'
                end          as output
    from      dual;I find this easier to debug and maintain.
    There's no denying, it does make the code very long. You be the judge of when to do this.
    You use parentheses and \ unnceccessarily sometimes. That's not really an error; if you find they make the code easier to develop and maintain, use them as much as you like.
    For example, about the 4th line of the regular expression as I formatted it above:
    '(\_?|\.)'     || --     optional underscore or dotUnderscore has no special meaning in regular expressions (only in LIKE), so you don't have to escape it.
    I might write that line:
    '(_|\.)?'     || --     optional underscore or dotjust because I think it's clearer.
    I think you forgot a \ about 7 lines later:
    '\.'          || --   dotBe very careful about testing patterns that include literal dots; always make sure that a random character, like ~ , fails in a place where a dot is expected.

  • Regular Expression Exclude Certain Characters

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

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

  • 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

  • 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 this regular expression work in detail

    Who can tell me how does the following regular expression work step by step, thanks!
    string input = "PRIVATE11xxPRIVATE22xx123PRIVATE33";
    string pattern = @"(?<Pvt>PRIVATE)?(?(Pvt)(\d+)|([^\d]+))";
    string publicDocument = null, privateDocument = null;
    foreach (Match match in Regex.Matches(input, pattern))
    if (match.Groups[1].Success)
    privateDocument += match.Groups[1].Value + "\n";
    else
    publicDocument += match.Groups[2].Value + "\n";
    Console.WriteLine("Private Document:");
    Console.WriteLine(privateDocument);
    Console.WriteLine("Public Document:");
    Console.WriteLine(publicDocument);

    Hi Sincos,
    sure:
    Your regular expression has two main blocks:
    1. (?<Pvt>PRIVATE)?
    That means find a string PRIVATE with zero or one repetition. This is a named capture group with the name "Pvt" to access it later
    2. (?(Pvt)(\d+)|([^\d]+))
    That's a conditional Expression with a yes and no clause. So let's split this one up:
    The first part (Pvt) means whether the string "PRIVATE" was found or not.
    When it was found, this gets active: (\d+)
    When it was not found, this gets active: ([^\d]+)
    So let's look at those two:
    (\d+) means a numbered capture Group. So one or more numbers
    ([^\d]+) means any character that is not in [\d], so not a number, with one or more repetitions
    Ok. So your regex ends up with three groups:
    1 Group: Numbered Group for [\d+]
    2 Group: Numbered Group for [^\d+]
    3 Group: Named Group for the string "PRIVATE"
    Now let's look at your input string "PRIVATE11xxPRIVATE22xx123PRIVATE33"
    With that one you'll have four matches:
    1st match "PRIVATE11"
      1 Group: "11"
      2 Group: -
      3 Group (Pvt): "PRIVATE"
    2nd match "xxPRIVATE" (String private was not found, so [^\d+] is used (any character not a number))
      1 Group: -
      2 Group: "xxPRIVATE"
      3 Group (Pvt): -
    3rd match "xx" (String private was not found, so [^\d+] is used (any character not a number))
      1 Group: -
      2 Group: "xx"
      3 Group (Pvt): -
    4th match "PRIVATE33"
      1 Group: 33
      2 Group: -
      3 Group (Pvt): "PRIVATE"
    Now let's look at your code:
    foreach (Match match in Regex.Matches(input, pattern))
    if (match.Groups[1].Success)
    privateDocument += match.Groups[1].Value + "\n";
    else
    publicDocument += match.Groups[2].Value + "\n";
    The Groups-Property of the Match contains 4 values. At index 0 there's the match itself. Index 1, 2 and 3 contain the
    three groups I've described above. So first you check if match.Groups[1].Success. That group is the first Group that stands for [\d+]. That group is succeeded when the string PRIVATE was found and it is followed by a number. With your Input string
    the first and fourth match are succeeded for that one. Then you're adding that Number to your privateDocument-string-variable.
    In the else-block you're adding the Groups[2].Value to the publicDocument-string-variable. That's the second group that stands for  [^\d+]. So it is used for matches 2 and 3 with the two strings "xxPRIVATE" and "xx".
    That's it.
    I would recommend you to install a tool to play around with Regex. My favourite is Expresso. You can download it here:
    http://www.ultrapico.com/expressodownload.htm
    Thomas Claudius Huber
    "If you can't make your app run faster, make it at least look & feel extremly fast"
    My latest Pluralsight-courses:
    XAML Layout in Depth
    Windows Store Apps - Data Binding in Depth
    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com

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

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

  • Using regular expressions in content dictionaries

    I need to create a content dictionary containing regular expressions. I also need to use the "\" to escape some characters that would otherwise be regex meta-characters. When using a regex in a message filter, the "\" must be doubled because of parsing issues. This is clearly documented in the manual. What isn't documented is whether this must be done when the regex is within a content dictionary.
    Here's an example:
    if (mail-from == "@bad-domain\\.com$") { drop(); }
    I want to change this filter to:
    if (mail-from-dictionary-match("bad-domains")) { drop(); }
    So what do I put in the content dictionary, "@bad-domain\.com$" or "@bad-domain\\.com$"?
    Thanks,

    You should use this:
    "@bad-domain\.com$"
    The above tells the system to deference the "." (any character) to mean a literal period.
    If you used this,
    @bad-domain\\.com$
    What the system would match is "@bad-domain\.com", because the first backslash would dereference the second backslash, to be taken literally. So, the double backslashes is the wrong format.
    The only reason you see it in the final results when you've committed changes is that the system adds the backslash for you so that there's no error when it gets compiled.
    Also, you could have left the single backslash out completely too and it would probably work.
    "@bad-domain.com$"
    If you sed that as your pattern in the dictionary, it would match against these:
    @bad-domain.com
    @bad-domainncom
    @bad-domain1com
    @bad-domain&com
    basically, the "." means any character. But to be precise, you should only add one backslash in front of special characters. Here is a list of special characters:
    | ( ) [ { ^ $ * + ? .
    For a detailed explanation about special characters and how to use them, please see the Advanced User Guide.
    [https://supportportal.ironport.com/irppcnctr/srvcd?u=http://secure-support.soma.ironport.com/subproducts/x-c_series&sid=900001]

  • Regular expressions using jsp

    Hello Techies,
    I am having a text area inside a jsp file. When ever the end user gives input it must be submitted to the server.
    The real problem is when the end user gives special characters and double-quotes in this text area, jsp is preforming in abnormal way.
    Can u guys tell me how to resolve this issue. i.e how to solve regular expressions in jsp.
    Even though the end user gives special characters or double quotes we should take only the content.
    Looking forward for u reply.
    regards,
    Ramu

    The real problem is when the end user gives special characters and double-quotes in this text area, jsp is preforming in abnormal way.What do you mean with "jsp is preforming in abnormal way" ?
    A arbitrary JSP does not care about double-quotes.
    Can u guys tell me how to resolve this issue. i.e how to solve regular expressions in jsp.Usually the same way as you do it in a poj class.
    Nobody here knows how your JSP looks like and who handles the request when the form is submited or even who generates the model of the data displayed by your JSP.
    You have to provide us with more details.

  • Doubt in Regular Expressions

    I started learning Regular Expressions. I am stuck in following.
    http://java.sun.com/docs/books/tutorial/extra/regex/literals.html
    In the above url, i didnt understand following:
    "Note that while the input string is 3 characters long, the start index is 0 and the end index is 3. By convention, ranges are inclusive of the beginning index and exclusive of the end index"
    I didnt understand why the end index is 3 instead of 2.

    exclusive of the end index means that the end
    index is the last index of the match + 1 (one
    character after the last index).
    Since the last index of the match is 2, then the end
    index will be 3.I am finding it hard to understand. Could you please explain in bit more detail. As i am in starting stage, i want to understand it clearly.

  • Unicode regular expression

    In the document, Unicode Technical Standard #18, Unicode Regular Expressions, there is a example in section 1.3.
    [\p{L} - QW]      Match all letters but Q and W
    so I tried with the following Java code:
    searchStr = "b"; // not mater it is Q or W
    Pattern searchPattern = Pattern.compile("[\\p{L} - QWZ]");
    Matcher m = searchPattern.matcher(searchStr );
    if(m.find())
    matched = true;
    And the result is always true. My understanding is that If the searchStr has substring "Q" or "W", then it should return false.
    did I miss something?
    Thanks

    Some details: Java's regex engine doesn't support the subtraction inside a character class like that.
    So, if I'm not mistaken, the regex:
    "[\\p{L} - QWZ]"really means: a
    - unicode letter ("\\p{L}")
    or
    - a character from the range white space up to white space (" - ")
    or
    - a Q, W or Z ("QWZ")
    And that's why it matches your "Q" and "W" substrings.

  • Item Validation using Regular Expression

    Hi,
    I am trying to apply a Validation to a text field item, with the type as Regular Expression.
    The text input into the field should be in a HH:MM:SS format, ie 05:30:00 (for 5:30am).
    The text I am placing in the 'Validation Expression 2' box is:
    [0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]
    This doesn't seem to work and I get an error message when I enter text in the correct format.
    I have even tried to use other comparisons, for example:
    or
    .{8}
    but these still give me an error message.
    Anyone have any ideas?

    Thanks for your help Flavio, the Regular Expression tool is really helpful.
    When I use this tool to compare strings with my regular expression, I get output = TRUE, which means I'm getting it right, but for some reason when I copy the same Regular Expression syntax into APEX, it doesn't work.
    I try to input correct strings into the field that is validated by the Reg Expr, but it still gives me an error.
    It seems to be something I am doing wrong within the application, but I can't figure out what I'm missing.
    I am creating an Item Level Validation with details:
    Type: Regular Expression
    Validation Expression 1: P23_BUS_DAY_COVERAGE_START
    Validation Expression 2: ^(([0-1][0-9])|(2[0-3])):[0-5][0-9]:[0-5][0-9]$
    Has anyone had similar problems using regualr expression validation in APEX?

  • Search with regular expression like this "[^\(]+mytype"

    I tried regular expression which find me line which has "mytype" but does not precede with "("
    I wrote it like this:    [^\(]+mytype
    It works perfectly with python reg exp. But it does not work in MSVC 2013 search(ctrl+shift+f). Do you know why? Is it bug?
    Is there a way to find variable definition with search function through whole project

    Hi Vit,
    According to your description, you mean that when you use the
    ctrl+shift+f shortcut key to search which line has "mytype" word in the whole project from VS2013 IDE like the following screen shot, but it does not work
    in VS2013 IDE, am I right?
    If yes, could you please provide me a screen shot about how you search the
    mytype?
    Generally, when we used the
    ctrl+shift+f shortcut key to search, it works fine in VS IDE. Therefore, to check if you install some third-party Add-ins impact your VS IDE, I suggest you can search
    the mytype in VS safe mode check if you get same issue.
    Reference:
    http://msdn.microsoft.com/en-us/library/ms241278.aspx
    (1)If you did not get same issue, I doubt that you may be install some Add-ins impact the VS IDE, so I suggest
    you can try to disable or un-install them and then check this issue again.
    (2)If you still get same issue, I suggest you can try to reset the VS setting file or you can try to repair your
    VS check this issue again.
    In addition, I suggest you can try to use Ctrl + F shortcut key to search the mytype word.
    If I misunderstand your issue, please provide me more detail message about your issue.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • 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