URGENT !!!  need regular expression

Hi ,
I need a regular expression  for a text field
What if we left the 3 character limit on alphanumeric characters (a-z/A-Z) and remove the limit for numeric characters only (0-9)?
Thing is  if user enters alphanumeric values then there should be limit  of 3 characters for the text filed.
if user enter numeric values then there be no limit .
i think i have given a clear explanation regarding my question....
any replies are appreciated..
thanks
bharathi..

Try the following in the change event:
r=/^[a-z]{1,3}$|^\d+$/i;
if (!r.test(xfa.event.newText))
xfa.event.change="";
Kyle

Similar Messages

  • Need Regular Expression?

    Hi all,
         I need the regular expression to find out any other characters present in the given string apart from the expression given (0-9,A-Z,a-z,._(underscore),-(hyphen),space). Thanks in advance.

    DarrylBurke wrote:
    Good regexes don't need to be obfuscated, and any attempt to do so is liable to render them more lucid :-\
    dbHeh, well, x = -x; doesn't need to be obfuscated either!

  • Need regular expression for oracle date format 'DD-MON-YYYY'

    Hi,
    Can anybody tell me the regular expression to validate date in 'DD-MON-YYYY'.
    My concept is i have a table with just two columns item_name and item_date
    Both fields are varchar2 and i want to fetch those records from this table which have valid date format('DD-MON-YYYY').

    If it must be a regexp, this is a starter for you, note it carries the caveats mentioned by both posters above and in the linked thread
    mkr02@ORA11GMK> with data as (select '10-jan-2012' dt from dual
      2  union all select '10-111-2012' from dual
      3  union all select 'mm-jan-2012' from dual
      4  union all select '10-jan-12' from dual)
      5  select
      6  dt,
      7  case when regexp_like(dt,'[[:digit:]]{2}-[[:alpha:]]{3}-[[:digit:]]{4}','i') then 1 else 0 end chk
      8  from data
      9  /
    DT                 CHK
    10-jan-2012          1
    10-111-2012          0
    mm-jan-2012          0
    10-jan-12            0It will not validate content, only string format.
    And to emphasis the points made in the linked thread - dates in text columns is poor design. Always.

  • Need Regular Expression to convert URL to Hyperlink

    I need Help Please..........
    I am fairly new to Java and really new to Reg Exp. I have a String that has normal text and may contain a URL. I would like to display the URL as A hyperlink using JSP.
    Can anyone help.

    This is actually not that hard, if you know where the text is located? Using the regex you can find the beginning and ending pattern of text that you are looking for. Then extract the data and put it into a variable. add stuff to it if you need by concatenating it like: "http://"+variable+".com" what every you need.
    something like this will help.
    String page = new String("");
              String inputLine;
              // This is sorta strange, but I use the concat to put the whole string on one line.
              // besides it is just for looking through. I use the trim() to get rid of whitespace.
              while ((inputLine = in.readLine()) != null)
                  page = page.concat(inputLine.trim());
             // The "URL:" is basically a pattern match to find in your text file.
             // and the font tags are where the data is to be extracted between, by using the split()
             //  I used this to extract data from Websites, but you can use it on text files, xml files, etc...
             // as long as you can pattern match.
              String urlString = (String)(page.split("\\<[Bb]\\>URL:\\</[Bb]\\>")[1].split( 
              "\\<font size=\"-1\"\\>")[1].split("\\</font>")[0].trim()); 

  • Need help in unix regular expressions

    Hi All,
    I'm new to shell scripting. Please help me in achieving this
    I am trying to a find regular expression that need to pick a file with begin with the below format and mask variable is called in xml file.
    currently the script accepts:
    mask="CLIENT_ID+'_ADHSUITE_IN_'+date2str(now,'MMddyy','US/Eastern')+'.txt'"
    But it should accept in the below format
    2595_ADHSUITE_IN_ANNWEL_030309_2009-02-10_15-12-46-000_648.TXT715.outpgp_out
    where CLIENT_ID=2595. How to place wild card character '*' in the below to accept file in the above format. here is what i made changes.
    mask="CLIENT_ID+'_ADHSUITE_IN_'*+date2str(now,'MMddyy','US/Eastern')*+'.TXT'*+'.outpgp_out'"
    Please help.
    Thanks

    I believe your statement is being passed over twice:
    First Pass: (This is done by something like javascript)
    CLIENT_ID+'_ADHSUITE_IN_'+'.*'+date2str(now,'MMddyy','US/Eastern')+'.*'+'.TXT'+'.*'+'.outpgp_out'In this pass the variables and functions that are enclosed in literals are processed:
    (1) CLIENT_ID is replaced by 2595 or whatever is current value is:
    (2) date2str(now,'MMddyy','US/Eastern') gets replaced by 040609 (if the current time now is 4th april 2009).
    So at the end of this first pass we have a string:
    2595_ADHSUITE_IN_.\*040609.\*.TXT.*.outpgp_outThis string at the end of the first pass is a Posix basic regular expression. (ref: [http://en.wikipedia.org/wiki/Regular_expression] ) accessed at time of post).
    This is the string I put in the Regular Expression text box on [http://www.fileformat.info/tool/regex.htm]
    and it matches "2595_ADHSUITE_IN_ANNWEL_040609_2009-01-27_17-02-28-000_631.TXT715.outpgp_out" for me (though I prefer my egrep test).
    I hope this is somewhat clearer. Remember I have very little information about your system/application and I make big guesses.
    NB: (I should thank Frits earlier for pointing my sloppiness between wildcards (for eg unix shell filename expansion) and regular expressions).
    For the second pass this used to compared other strings to see

  • I need help renaming a file using regular expressions in Bridge.

    Hi,
    I work at a university, and we are working through files for our Thesis and Dissertations. We have been renaming them to make them more consistent. I am just wondering if there is a regular expression that could help with this process?
    Here is come examples of current file names;
    THESIS 1981 H343G
    Thesis 1981 g996e
    THESIS-1981-A543G
    I don't need to change the actual names of the files. just how they are formatted.
    Proper case on Thesis.
    Hyphens(-) in all white space.
    First letter capital, last letter lowercase on the call no (H343g)
    So the list above should look like;
    Thesis-1981-H343g
    Thesis-1981-G996e
    Thesis-1981-A543g
    I have seen people do some pretty cool things with regular expressions! Any help would be greatly appreciated. Thanks!

    You would be better off using a script to do this as an example as I don't think it would be possible in the Bridge re-name.
    Using ExtendScript Toolkit or a Plain text editor copy the code into either and save it out as Filename.jsx
    This needs to be saved into the correct folder. this is found by going to the preferences in Bridge, selecting Startup Scripts, this will open the folder where the script is to be saved.
    Once this is done close and re-start Bridge.
    To Use: Goto the Tools Menu and select Rename PDFs
    Make sure you test the code with a few copied files into a seperate folder first to make sure it does what you want.
    The script will do all PDF files in the selected folder.
    #target bridge 
    if( BridgeTalk.appName == "bridge" ) { 
    renamePDFs = MenuElement.create("command", "Rename PDFs", "at the end of Tools");
    renamePDFs.onSelect = function () {
    app.document.deselectAll();
    var thumbs = app.document.getSelection("pdf");
    for( var z in thumbs){
    var Name = decodeURI(thumbs[z].spec.name);
    var parts = Name.toLowerCase().replace(/\s/g,'-').match(/(.*)(-)(.*)(-)(.*)(\.pdf)/);
    var NewName = parts[1].replace(/^[a-z]/, function(s){ return s.toUpperCase() });
    NewName += parts[2]+parts[3]+parts[4]+parts[5].toUpperCase().replace(/[A-Z]$/, function(s){ return s.toLowerCase() });
    NewName += parts[6];
    thumbs[z].spec.rename(NewName);

  • Help needed regarding regular expressions

    hello
    i need to write a program that recieves a matematical expression and evaluates
    it...in other words a calculator :)
    i know i need to use regular expressions inorder to determine if the input is legal or not ,but i'm really having trouble setting the pattern
    the expression can be in the form : Axxze2223+log(5)+(2*3)*(5+4)
    where Axxze2223 is a variable(i.e a combination of letters and numbers.)
    where as: l o g (5) or log() or Axxx33aaaa or () are illegal
    i tried to set the pattern but i got exceptions or it just didnt work the way i wanted it .
    here's what i tried to do at least for the varibale form:
    "\\s*(*([a-zA-Z]+\\d)+)*\\s*";
    i'm really new to this...and i can't seem to set the pattern by using regular expressions,how can i combine all the rules to one string?
    any help or references would be appreciated
    thanks

    so i'll explain
    let's say i got token "abc22c"(let's call it "token")
    i wan't to check if it's legal
    i define:
    String varPattern = "\\s*[a-zA-Z]+\\d+\\s*";If you want to check a sequence of ASCII characters, longer than one, followed by a single digit, the whole possibly surrounded by spaces -- yes.
    >
    now i want to check if it's o.k
    so i check:
    token.matches(varPattern);
    am i correct?Quite. It's better to compile the Pattern (Pattern.compile(String)), create a java.util.regex.Matcher (Pattern#matcher(CharSequence)), and test the Matcher for Matcher#matches().
    (Class.method -> static method, Class#method -> instance method)
    >
    now i'm having problem defining pattern for log()
    sin() cos()
    that brackets are mandatory ,and there must be an
    expression inside
    how do i do that?First, I'd check the overall function syntax (a valid name, brackets), then whether what's inside the brackets is a valid expression (maybe empty), then whether that expression is valid for that function (presumably always?).
    I might add I'm no expert on parsing, so that's more a supposition than a guide.

  • Regular expressions its URGENT !!!

    i have a long string of regular expressions seperated by "|" and i need to know which regular expression the particular string matched how can i find that and can i do it using java .util.regex
    thanks in advance

    Consider to use "capturing groups" or a better solution should be to split this long regular expression with alternations in small ones that will cause considerable reduction in backtracking. Also in this way will be easier to find what regular expression matches the target string.
    Regards.

  • Need help in writing regular expressions involving \w

    Hi,
    Here is my requirement .
    I have a string : GTA - 12AB TRA - 12AB
    I need a regex that represent above string.
    GTA - Constant - This wont change
    12AB - This will be \w (alphanumeric)
    Here I cannot have TRA within this 4 characters.
    The question is :
    How can I write an expression which says it can be a word(the positions where I have 12AB in example) but not TRA in sequence.
    Is this doable?
    Thanks in advance.

    Use lookarounds: [http://www.regular-expressions.info/lookaround.html]
    The regex:
    (?!.?TRA).{4}matches any 4 characters (except line breaks) that does not contain 'TRA'.

  • Need to remove Commas REgular Expressions?

    How can I use java to remove commas from a number.
    1,000 string
    need it to be
    1000
    can I pass it through some sort of regular expression?

    I was attempting to do it with regular expressions to learn how to do them better.
    Thanks for your good comment.
    nupevic

  • Need help for a more complicated regular expression

    Hi everyone,
    I got another more complicated one here.
    I need to split  '+0,+0.00000000E+000, -4.76517000E+001,-4.64744200E+001,-6.18140500E+001,-5.93055600E+001' by ',' into an array without '+0,+0.00000000E+000'.
    I am using a regular expression as  '[+-]([0-9]+[1-9]+)[E][+]\d' but it failed to, just wondering what is happening there.
     Any idea is well appreciated,
    Thanks,
    +Kunsheng
    Message Edited by Kunsheng Chen on 03-05-2009 05:09 PM
    Solved!
    Go to Solution.
    Attachments:
    regular.vi ‏33 KB

    First, don't bother with regular expressions. Use the function Spreadsheet String to Array with a commas as the delimiter, %f as the format string, a 1D array of floats as the array type. Next, delete the first two elements from the results and you're done.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • 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

  • 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

  • Need a regular expression for the text field

    Hi ,
    I need a regular expression for a text filed.
    if the value is alphanumeric then min 3 char shud be there
    and if the value is numeric then no limit of chars in that field.[0-9].
    Any help is appriciated...
    thanks
    bharathi.

    Try the following in the change event:
    r=/^[a-z]{1,3}$|^\d+$/i;
    if (!r.test(xfa.event.newText))
    xfa.event.change="";
    Kyle

  • Regular expression help needed

    Hello experts,
    I am looking to implement a search & replace regular expression
    my regular expressions are as follows:
    search regular expression = (test\\s+--\\s*)?this is a test(.*)?
    replace regular expression = (new) brand new test$2
    i.e. The results I require are
    case 1
    input string = test -- this is a test 1999
    correct result = (new) brand new test 1999
    or (since I require the regular expression to be optional)
    case 2
    input string = this is a test
    correct result = brand new test
    How do I implement this using pattern and matcher? Sample code would be useful
    I am having difficulties because matcher.appendReplacement will always replace because my regular expressions are optional. (which is incorrect)
    i.e. I am getting the following incorrect result ((new) is being appended)
    input string = this is a test
    incorrect result = (new) brand new test
    At the moment my non working code is
    StringBuffer sb = new StringBuffer();
    Pattern pattern = Pattern.compile("(test\s+--\s*)?this is a test(.*)?");
    Matcher matcher = pattern.matcher("this is a test");
    if(matcher.find())
    matcher.appendReplacement(sb, "(new) brand new test$2");
    String result = sb.toString();
    System.out.println(result);
    }In the above scenario I want the output to be 'brand new test' without the (new) because the input string did not contain 'test --'
    Hope this makes sense
    Thanks

    For example: StringBuffer sb = new StringBuffer();
    Pattern pattern = Pattern.compile("(test\s+--\s*)?this is a test(.*)");
    Matcher matcher = pattern.matcher("this is a test");
    if(matcher.find())
      matcher.appendReplacement(sb, ""); // copy everything before the match
      if (matcher.start(1) != -1)
        sb.append("(new) ");
      sb.append("brand new test");
      sb.append(matcher.group(2));
    matcher.appendTail(sb); // copy everything after the match
    System.out.println(sb.toString()); Because the first group is optional, you need to find out whether it participated in the match before you add the "(new) " bit. The second group doesn't need to be optional because (1) the subexpression with the group can match nothing, and (2) you don't need to perform a different action depending on what that group did. You just append the captured text, which may be an empty string.

Maybe you are looking for

  • Mount external hard drive on boot

    I have a Mac mini run on SL, I want to set it up as a samba server with a external hard drive which formatted in NFS format. I tried to write a plist in LaunchDaemons to call a script to mount the hard drive, but it does not work. Here is my plist <?

  • Quit Application with "Alt+F4" or "X"-Button

    I have created an application with LabWindows/CVI 5.0. To quit the application I have created a Callback Function which takes care of it. My problem is now that I'd like also to shut down the application the "standard" windows way with "Alt+F4" or th

  • A question about SAP Web Dispatcher

    Following paragraph is copied from TADM10_2 book, Page 39 (Participant Handbok, 2005Q4, 50074912). My question is why there are two same  items - ABAP-only scenario? I might be print issue. The SAP Web Dispatcher can be used for load balancing in the

  • How to connect two BW systems to one ECC system?!?

    Hi Experts! We want to connect our ECC system (P11) to multiple SAP BW systems. Therefore we made a system copy of our productive BW System (P81) and create a new second BW System (T81). When I want to restore to connection to the P11 in the T81, Iu2

  • SunOne web server sp6 on RH9

    Dear all, I would like to install SunOne web server sp6 on Redhat 9.0 for evaluation. I set some parameters as following. * make libncurses.so.4 link file * set LD_ASSUME_KERNEL=2.4.1 * change name from netscape to mozilla in startconsole. * set fire