Validate Email by regular Expression... Need Help

Dear All,
Requirement:
validate the email ID entered & throw error message, if it is invalid.
DATA c_mailpattern TYPE c LENGTH 60 VALUE
'[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4} '.
** If @ is present, more than once. Error out
    find ALL OCCURRENCES OF '@' in P_email
    MATCH COUNT v_count.
    if v_count > 1.
      v_badpattern = 1.
    endif.
** If , is present, once, Error out
    find ALL OCCURRENCES OF ',' in P_Email
    MATCH COUNT v_count.
    if v_count > 0.
      v_badpattern = v_badpattern + 1.
    endif.
    FIND REGEX c_mailpattern IN P_Email IGNORING CASE .
    IF sy-subrc <> 0 OR v_badpattern > 0.
Write:/ p_EMAIL, 'has invalid Email format'.
ENDIF.
though this works fine, tester needs me to catch, if domain name has "app.com.com"  as invalid email id.
above regex fails in such case.
I searched & found
{messageID=3706355}
messageID=1657369}{
https://wiki.sdn.sap.com/wiki/display/Snippets/E-MAIL+Validation
doesn't help.
I found this regex in a perl program.
[a-z0-9!#$%&'{size:14}*+{size:14}/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Can I get help to modify this  into ABAP String?
1) I can't bypass the boldened text using Escape characters like #* or '' Can some one help me assign this regex-string into a string variable?
2) This regex is longer than allowed length for a literal.
It can be split into 2 strings, then concatenated & checked.
Edited by: Mallikarjuna J on May 16, 2011 8:23 PM
Edited by: Mallikarjuna J on May 16, 2011 8:26 PM

Thanks Sebastian, Pratik & Keshav for the replies.
SX_INTERNET_ADDRESS_TO_NORMAL doesn't validate a wrong email ID. It only splits the internet address into mail & domain.
Prathik,
just .com.com is not the point, Bad input could be .net.ent or .net.com or so....
Amol, Thanks, but I keep receiving Error, not found in the 41 line response I get
I think we need to check not line 2 but line 28.
Taking cue from Prathik, I'm planning to put this
*** ls_inputmail-mail is the email-id entered by user.
************ Check for Valid Regular Expression
*****   DOT(.) is allowed more than once,
*****   @ is allowed only once,
*****   , is not allowed.
** If @ is present, more than once. Error out
    find ALL OCCURRENCES OF '@' in ls_input_mail-mail
    MATCH COUNT v_count.
    if v_count > 1.
      v_badpattern = 1.
    endif.
** If , is present, once, Error out
    find ALL OCCURRENCES OF ',' in ls_input_mail-mail
    MATCH COUNT v_count.
    if v_count > 0.
      v_badpattern = v_badpattern + 1.
    endif.
**   Find if domain part i.e., after @ has errors.
    SPLIT ls_input_mail-mail at '@' into v_mailpart v_domain.
*    there's a dot in the domain.
    if v_domain Co '.' .
*     last 2 char can only be country name, not anything else.
      SPLIT v_domain at '@' into v_domain1 v_domain2.
*      v_domain2 can only be a country name, else error out
  select single landx from t005 into v_country
    where landx = v_domain2.
    if sy-subrc <> 0.
      v_badpattern = v_badpattern + 1.
    endif. 
    ENDIF. 
    FIND REGEX c_mailpattern IN ls_input_mail-mail IGNORING CASE .
    IF sy-subrc <> 0 OR v_badpattern > 0.
Write:/ ls_inputmail-mail, 'has invalid email format'.
  ENDIF.
However, I was wondering, if there was a way to  use escapae characters & make the beow string as a valid regex variable to check email id.
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Nevertheless, Thanks Friends for all your inputs.
Edited by: Mallikarjuna J on May 17, 2011 2:23 PM

Similar Messages

  • Java Regular Expression Need Help

    I want regular Expression that accept all numbers and it should skip the numbers if it comes in {}

    No this is not workingThen you need to be MUCH clearer as to exactly what you are trying to acheive...
    We aren't mind readers... try posting the string you are parsing and the exact result that you want to get

  • How to Validate this using Regular Expressions

    Hi All,
    I have following types of Mail IDs, Each is a String.
    It may be either of the Following:
    [email protected]
    or
    Ameer<[email protected]>
    Then How to validate using the Regular Expressions.

    use this regex.. might need to convert it from perl regex flavor:
    (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
    \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
    ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[
    \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
    31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
    ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
    (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
    (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
    ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
    r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
    \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
    ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
    )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
    \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
    )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
    *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
    |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
    \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
    \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
    ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
    ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
    ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
    :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
    :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?
    :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
    [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\]
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|
    \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
    @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"
    (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
    :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[
    \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-
    \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(
    ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
    :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
    ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
    .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
    ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
    [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
    r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\]
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
    |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
    00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
    .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
    ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
    :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
    ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
    ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
    ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
    ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
    \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
    ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
    ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
    :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
    \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
    [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
    ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
    ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
    ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
    ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
    @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
    \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
    ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
    \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
    "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
    *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
    +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
    .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
    ?:\r\n)?[ \t])*))*)?;\s*)

  • Help with regular expression needed

    Hi,
    Perhaps someone here can help me with my regular expression I'm trying to build in my Java code.
    The regular expression that I'm looking to build consists of any non-whitespace character up until it finds one or two <>= symbols and then any character thereafter. So both these Strings would match the expression:
    City 1==London
    Age>=18
    The regular expression that I'm using is as follows:
    (\\S+)([><=]){1,2}(.+)However, group 1 always retrieves the first <>= symbol as in "City 1=". How can I make the <>= part greedy so that it retrieves both operator symbols?
    Thanks.

    Make the first group, the non-spaces, reluctant:
    "(\\S+?)([<>=]{1,2})(.+)"

  • Question about Regular Expressions, please help!

    I have created an app which reads files and extracts certain data using regular expressions in JDK1.4 using Pattern and Matcher classes.
    However it needs to run on JDK1.2.2 (dont ask). The regular expression classes are not available in 1.2.2 (the Pattern and Matcher class) so i am looking for something similiar which i can use?
    I need something that loops through all the matches found in the file like how Matcher works i.e.
    while (matcher.find())
    // do this
    Help!

    http://jakarta.apache.org/regexp/

  • Regular Expressions, please help.

    Hello everyone.
    Can I get a Java Regular Expression to match with a word of the following language...
    Start --> Expression;
    Expression --> [0-9]+;
    Expression --> Expression * Expression;
    So the regexp should match with words like:
    4;
    4664;
    4 * 763;
    5 * 4534 * 23534;
    04 * 002 * 1 * 10 * ...
    I would be very happy, if anyone could help.

    I dont think that I need to learn anything more.
    I am sure it is not possible to make, what I want.
    I want to build a compiler.
    I just finished the abstract syntax of my language. Now I need a possibility to compile the concrete syntax of my language to the abstract one.
    But I think, it is not possible with regular expressions.
    Cause I need possibility to match a syntax of type chomsky 2.
    I think regular expressions only match chomsky 3 languages.
    But the "Backtracking"-mechanism of Java RegExp could do this.
    I am not sure with this.
    If you have any ideas please post.

  • Validate cfinput using regular expression

    Hi,
    can somebody help me valditing an cfinput field using regular expressions?
    First digit must be a number or "R".
    Digit 2-15 can be everything without special characters. Digit 2-15 can also be empty.
    I try this, but it doesn't work (Sorry I'm a beginner using regex).
    <cfinput type="text" name="field1" required="yes" validate="regular_expression"  pattern="[0-9Rr][0-9a-zA-Z]*"  maxlength="15">
    Thank you in advice!
    Claudia

    You haven't told your regex to match the entire string, so it will "pass"
    any string that has your match anywhere within it, so like as long as it's
    got an R or a digit in it: it's OK.
    To tell it to match the entire string, anchor it to the start and end of the
    string with ^ and $ respectively.
    Regular expression syntax: Using special characters
    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0a38f -7ffb.html#WSc3ff6d0ea77859461172e0811cbec0a38f-7fef
    Adam

  • Email Validation - Regular Expression

    Hi,
    I want to validate the form of an email address using a regular expression. I have come across one, but I get an error.
    Pattern p = Pattern.compile("^([a-zA-Z0-9_\-])+(\.([a-zA-Z0-9_\-])+)*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9])+(([\-])+([a-zA-Z0-9])+)*\.)+([a-zA-Z])+(([\-])+([a-zA-Z0-9])+)*))$");the error is: Invalid escape sequence.
    It underlines the first set of characters in the expression... from ^([a-zA-Z0-9_\- 
    any ideas?  or does anyone have a good regular expression for validatin emails in java??
    Thanks
    Craig                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    This email address is also valid by RFC 2822
    this!strange%[email protected]
    Your RE does not consider such addresses...
    Some validations also check if the domain ends with a
    2-letter country code, or
    'com'/'org'/'biz'/'info'/'museum' etc.
    Not to mention that email addresses can have comments in them as well.

  • Quick regular expression question/help

    Can someone help me with two regular expressions I need. I could spend a while trying to figure it out myself, however times short and I really would like to get a fool proof optimal solution (my attempt would be buggy).
    Sample sentence
    The population, is projected to reach 200,000, or more (by 2020).[7] This is {dummy} text.
    The first regular expression
    I need all brackets and every thing between them to be removed from a sentence.
    Brackets such as: ( ), [ ] and { } .
    I.e. Given the above sentence the following would be returned:
    The population, is projected to reach 200,000, or more. This is text.
    The second regular expression
    If a word has a trailing comma character I need to add a whitespace between the word and the comma.
    I.e. Given the sentence returned from the first regular expression, this regex would return:
    The population *,* is projected to reach 200,000 *,* or more. This is text.
    Many thanks to anyonewho can help me with this!
    Edited by: Myles on Jan 18, 2008 8:12 AM

    http://java.sun.com/docs/books/tutorial/extra/regex/index.html
    http://www.regular-expressions.info

  • Regular Expression query help.

    Hi, your help will be appreciated,
    I need to replace the a string's pattern with some special characters.
                            Input String := 'mytext*% align="quot;leftquot;><font face="quot;Arialquot;"> *% align="quot;leftquot;"><this is text><p this to replace >'
                            Output String := 'mytext@ align="quot;leftquot;$<font face="quot;Arialquot;"> @ align="quot;leftquot;"$<this is text><p this to replace >'
    Replacing Rules:
    1)              '*%'             should be replaced by '@'
    2)              '>'            should be replaced by $ (only the EVERY FIRST occurrence after the character @ )
    Tried with REGEXP but looks like need your help!
    Thx
    DJ.

    Hi, DJ,
    DeeJay wrote:
    Perfect Frank. Thanks for your help.
    Could you please explain how it is working? you know, these Regexps are hurdle for me always in understanding.Not just you; regular expression can be very cryptic.
    We're saying "replace '*%x>' with '@x$', where x is 0 or more characters from the set of all characters except '>'.
    {code}
    SELECT     REGEXP_REPLACE ( 'mytext*% align="quot;leftquot;> *% align="quot;leftquot;"><this is text>'
              , '\*'     || -- aserisk (special character, must be escaped)
              '%'     || -- percent sign
                   '('     || -- begin \1 definition
                   '['     || -- begin set definition
                   '^' || -- "The set consiting of all characters EXCEPT ...
                   '>' || --     ... the greater-than sign"
                   ']'     || -- end set definition
                   '*'     || -- 0 or more characters from the preceding set
                   ')'     || -- end \1 definition
                   '>'     -- greater-than sign
              , '@\1$'
              )     AS txt
    FROM     dual;

  • I need a solution for the security questions please ?? In the other hand i can't use the rescue email !! I need help .

    I need help for those security questions please !! I don't have a rescue email and even i don't know how to add it ! Please help me

    I didn't mean to give me an answer for the security questions i mean that i didn't remember the answers and i don't have a rescue email to send in it , i'm just ask for sloution to reset my security questions got it?

  • Regular expression (regex) help!

    I am trying to write a correct regular expression but am having difficulties.
    I have a webpage saved as a string and want to extract all the links (urls) from the webpage string.
    The trouble I am having is that some websites surround links using double quotes " " and some use single quotes ' ' around links in html:
    Double quotes around url:
    <a href="www.example.com"></a>
    And single quotes:
    <a href="www.example.com"></a>
    So far I have a regex which extract links if they are surrounded with double quotes (see below), however if a page uses single quotes it screws up ;)
    Pattern.compile("<a\\s+href\\s*=\\s*\"?(.*?)[\"|>]",  Pattern.CASE_INSENSITIVE);So is there a way to say look for double quotes OR single quotes?
    Many thanks
    null

    There's no need to escape the single-quote (or apostrophe) in a regex. The only reason it was necessary to escape the double-quote (or quotation mark) is because the regex was written in the form of a String literal. Neither the single-quote or the double-quote has any special meaning in regexes.

  • Stripping HTML thru regular expression(pls help)

    Hi all..
    I've been trying to use the regular OROMatcher-1.1 expression package downloaded from apache.org.
    it works well with my program but i m having problems building correct regular expression to strip off HTML tags.
    can any of u help me build an expression tha strips of ALL html tags including those with funny spaces such as:
    <a href = "www.here.com">click me</a>
    do help pls. i've tried for ages and its driving me mad

    Hi,
    Wont go into much details but the simplest way to do that would be using XML technology. Try using SAX or DOX whatever you feel comfortable with. I think SAX would be a better choice. For details visit
    http://java.sun.com/xml/?frontpage-spotlight
    /khurram

  • Regular expression needed to escape dots

    Hello
    In a file , I might have several times a line like this :
    VALOR DESCUENTO .......                           1,505,728.80What is the regular expression to get *1,505,728.80* ? Please note that there are dots ..how do i escape them ?
    This is what I use , but it does not work
    String descuentoPattern = "VALOR DESCUENTO(?:\\s+?)(?:^\\s+?)(?:\\s+?)(.*)"; cheers,
    deibys

    BigDaddyLoveHandles wrote:
    The same way you escape any character -- with a backslash.Remembering to double-up backslashes in Java strings, of course.
    @deibys, your regex is wrong. Try this instead:
    String foo = "VALOR DESCUENTO .......                           1,505,728.80";
    String pattern = "VALOR DESCUENTO\\s*\\.+\\s+(.*)";
    Pattern p = Pattern.compile(pattern);
    Matcher m = p.matcher(foo);
    if (m.matches()) {
         System.out.println("Match found: " + m.group(1));
    }

  • Forgot email and password. Need help! Newer mind g...

    Hello i need to get back my skype account and i dont know wich of my email is on that account becouse its been few years when i created account. Is it possible by using login nick name get back my account. For proof its my account i can tell ewerything what is on it. Please help!
    Newer mind got it back...

    Here are Two Ways to help you get your Gmail back click on both for the Info:  http://goo.gl/T9ot6   http://goo.gl/N6Ba0  b33

Maybe you are looking for