Regular expression to only allow numeric chars or spaces in tel num field

Hi folks
Am Apex Newbie using 4.0.1 / Vista / Oracle XE and am trying to create an item level validation on a tel number field.
I want any combination of numbers and spaces to be valid with only the obvious proviso that the field cant be completely spaces.
Can anyone help suggest how to do this as am really struggling with something so simple as I have no prev exp of reg expressions.
Many thanks as always
Peter

Hi,
it's quite strange, I just tried your input (without apostrophes) and it passed. Did you copied my reg exp (from ^ to $ included) and pasted it into Validation Expression 2 field of validation with type Regular Expression? It really should work.
Jirka

Similar Messages

  • Regular Expression for floating point numeric field

    Hi,
    the requirements for the field are as follows:
    - floating point numeric field 7 digits in length
    - the field must contain a decimal (dot) and either one, two or three digits to the right of the decimal
    - (leading zeroes are required if needed to fill up the 7 characters)
    My example shown below does not check for the length of 7 characters:
    public static void main(String[] args) {
        String str = "04100.0";
        System.out.println(str);
        Pattern f_1To7 = Pattern.compile("^([0-9]*\\.[0-9]{1,3})$");
        Matcher matcher = f_1To7.matcher(str);
        if (matcher.find()) {
            // yes, we've found something
            System.out.println("We matched the pattern!");
        } else {
            System.out.println("Better luck next time!");
    }When changing the pattern to
    ^([0-9]*\\.[0-9]{1,3}){7}$the whole expression will be repeated 7 times - but I would like to have to whole String to be 7 characters long.
    Here are some examples for the field:
    050.500 or 04100.0Thanks a lot and best regards,
    - Stephan

    Jackler wrote:
    Perhaps I did not express clearly enough. My problem is not a java issue - what I need is a regular expression (pattern) suiting my requirements:
    -floating point numeric field 7 digits in length
    -contains a decimal and either one, two or three digits to the right of the decimal
    ...Assuming that you are going to use Java*, you could use a lookahead at the start of your regex:
    "^(?=\\d{4,6}\\.\\d{1,3}$).{8}$"Meaning:
    ^             # match the start of the string
    (?=           #
      \d{4,6}     #   ensure that there are between 4 and 6 digits...
      \.          #   followed by a DOT...
      \d{1,3}     #   followed by 1 to 3 digits
    .{8}$         # match exactly 8 characters directly followed by the end of the string* or some other language that has look-ahead support (most PCRE implementations have them)

  • How to 'Only' allow Numeric value in the Edit Box in AcroDialogs

    Hi all,
    I've create an AcroDialog wizard, I need to allow onlu numeric values in the Edit Box. Can someone please help me with this validation?
    Regards,
    Chris

    There isn't a keystroke event for custom JavaScript dialogs, or any proper interactive events for the fields.  You can validate fields when the user presses OK, and you can test fields when the user changes focus by setting the "Action" property for the field.  But the only practical way to restrict user input to numbers is to use George's suggestion.  There is a number property for the fields but it has an undesirable side affect and I never use it.
    Thom Parker
    The source for PDF Scripting Info
    pdfscripting.com
    The Acrobat JavaScript Reference, Use it Early and Often
    http://www.adobe.com/devnet/acrobat/javascript.html
    Then most important JavaScript Development tool in Acrobat
    The Console Window (Video tutorial)
    The Console Window(article)

  • MS-LDAP usernames are 15 char long SAP only allows 12 Char

    I have a customer that has a MS-Active Directory consolidation project going on as well as an SAP implementation. There will need to be new standards set for the Active Directory and there will be a large data cleanup. I am not sure if they will use portal but it is an ECC, BI and PI implementation at least. They wish to set up Single sign on with LDAP.  The issue is some of their LDAP user names are 15 charcters long but SAP only accepts 12 characters - what will happen when we connect this up?
    Is there any way around it?
    Thanks in advance.

    Hello,
    but I would not cut off the username without searching for duplicates.
    A good way to solve this could be to introduce an IdM username based upon numbers, like A00001, A00002 and so on. And then join in the usernames from AD and SAP storing their usernames in the ACCOUNT attributes or something.
    For the duplicate check you could use the fields firstname, lastname, mail address, personal number, ... It can be a bit tricky though and you may need to manually synchronize some users, but this is worth it.
    Regards
    Dominik

  • JFormattedTextField Mask and regular expression

    Hi,
    I have to allow a user to enter numeric values only. The first 3 digits are mandatory, followed by a space, followed by a maximum of 20 digits,
    I am trying to use the regex formatter from Sun at
    http://java.sun.com/products/jfc/tsc/articles/reftf/
    Plus, I wanted to have a mask as well, so that the user does not have to type-in the space.
    So far, I haven't had any luck in getting to implement both.
    Any helps would be greatly appreciated.
    Thanks

    Hello,
    ... so that the users don't have to type-in the space?I don't see a solution with regular expressions for that, although I'm not an expert in that field. Let's take an example with a more "visible" character like "123-456", regex only checks, but doesn't display or jump over separator literals.
    Presently I can only see a solution in using a normal MaskFormatter
        MaskFormatter mf1;
        try
        { mf1 = new MaskFormatter("### #####");
        catch (ParseException e)
        JFormattedTextField tf = new JFormattedTextField();
        mf1.install(tf);If you install a field to a maskFormatter it doesn't oblige you to fully fill up the mask, as happens if doing a
    JFormattedTextField tf = new JFormattedTextField(mf1);
    This nicely jumps over the blank (or any other literal). However, you
    have to check whether at least three ciphers have been input. This could be done either in an Action- or Focus(Lost)Listener or by means of an InputVerifier.
    Greetings
    Joerg

  • Introduction to regular expressions ... continued.

    After some very positive feedback from Introduction to regular expressions ... I'm now continuing on this topic for the interested audience. As always, if you have questions or problems that you think could be solved through regular expression, please post them.
    Having fun with regular expressions - Part 2
    Finishing my example with decimal numbers, I thought about a method to test regular expressions. A question from another user who was looking for a way to show all possible combinations inspired me in writing a small package.
    CREATE OR REPLACE PACKAGE regex_utils AS
      -- Regular Expression Utilities
      -- Version 0.1
      TYPE t_outrec IS RECORD(
        data VARCHAR2(255)
      TYPE t_outtab IS TABLE OF t_outrec;
      FUNCTION gen_data(
        p_charset IN VARCHAR2 -- character set that is used for generation
      , p_length  IN NUMBER   -- length of the generated
      ) RETURN t_outtab PIPELINED;
    END regex_utils;
    CREATE OR REPLACE PACKAGE BODY regex_utils AS
    -- FUNCTION gen_data returns a collection of generated varchar2 elements
      FUNCTION gen_data(
        p_charset IN VARCHAR2 -- character set that is used for generation
      , p_length  IN NUMBER   -- length of the generated
      ) RETURN t_outtab PIPELINED
      IS
        TYPE t_counter IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
        v_counter t_counter;
        v_exit    BOOLEAN;
        v_string  VARCHAR2(255);
        v_outrec  t_outrec;
      BEGIN
        FOR max_length IN 1..p_length 
        LOOP
          -- init counter loop
          FOR i IN 1..max_length
          LOOP
            v_counter(i) := 1;
          END LOOP;
          -- start data generation loop
          v_exit := FALSE;
          WHILE NOT v_exit
          LOOP
            -- start generation
            v_string := '';
            FOR i IN 1..max_length
            LOOP
              v_string := v_string || SUBSTR(p_charset, v_counter(i), 1);
            END LOOP;
            -- set outgoing record
            v_outrec.data := v_string;
            -- now pipe the result
            PIPE ROW(v_outrec);
            -- increment loop
            <<inc_loop>>
            FOR i IN REVERSE 1..max_length
            LOOP
              v_counter(i) := v_counter(i) + 1;     
              IF v_counter(i) > LENGTH(p_charset) THEN
                 IF i > 1 THEN
                    v_counter(i) := 1;
                 ELSE
                    v_exit := TRUE;  
                 END IF;
              ELSE
                 -- no further processing required
                 EXIT inc_loop;  
              END IF;  
            END LOOP;        
          END LOOP; 
        END LOOP; 
      END gen_data;
    END regex_utils;
    /This package is a brute force string generator using all possible combinations of a characters in a string up to a maximum length. Together with the regular expressions, I can now show what combinations my solution would allow to pass. But see for yourself:
    SELECT *
      FROM (SELECT data col1
              FROM TABLE(regex_utils.gen_data('+-.0', 5))
           ) t
    WHERE REGEXP_LIKE(NVL(REGEXP_SUBSTR(t.col1,
                                         '^([+-]?[^+-]+|[^+-]+[+-]?)$'
                       '^[+-]?(\.[0-9]+|[0-9]+(\.[0-9]*)?)[+-]?$'
    ;You will see some results, which are perfectly valid for my definition of decimal numbers but haven't been mentioned, like '000' or '+.00'. From now on I will also use this package to verify the solutions I'll present to you and hopefully reduce my share of typos.
    Counting and finding certain characters or words in a string can be a tedious task. I'll show you how it's done with regular expressions. I'll start with an easy example, count all spaces in the string "Having fun with regular expressions.":
    SELECT NVL(LENGTH(REGEXP_REPLACE('Having fun with regular expressions', '[^ ]')), 0)
      FROM dual
      ;No surprise there. I'm replacing all characters except spaces with a null string. Since REGEXP_REPLACE assumes a NULL string as replacement argument, I can save on adding a third argument, which would look like this:
    REGEXP_REPLACE('Having fun with regular expressions', '[^ ]', '')So REPLACE will return all the spaces which we can count with the LENGTH function. If there aren't any, I will get a NULL string, which is checked by the NVL function. If you want you can play around by changing the space character to somethin else.
    A variation of this theme could be counting the number of words. Counting spaces and adding 1 to this result could be misleading if there are duplicate spaces. Thanks to regular expressions, I can of course eliminate duplicates.
    Using the old method on the string "Having fun with regular expressions" would return anything but the right number. This is, where Backreferences come into play. REGEXP_REPLACE uses them in the replacement argument, a backslash plus a single digit, like this: '\1'. To reference a string in a search pattern, I have to use subexpressions (remember the round brackets?).
    SELECT NVL(LENGTH(REGEXP_REPLACE('Having  fun  with  regular  expressions', '( )\1*|.', '\1')))
      FROM dual
      ;You may have noticed that I changed from using the "^" as a NOT operator to using the "|" OR operator and the "." any character placeholder. This neat little trick allows to filter all other characters except the one we're looking in the first place. "\1" as backreference is outside of our subexpression since I don't want to count the trailing spaces and is used both in the search pattern and the replacement argument.
    Still I'm not satisfied with this: What about leading/trailing blanks, what if there are any special characters, numbers, etc.? Finally, it's time to only count words. For the purpose of this demonstration, I define a word as one or more consecutive letters. If by now you're already thinking in regular expressions, the solution is not far away. One hint: you may want to check on the "i" match parameter which allows for case insensitive search. Another one: You won't need a back reference in the search pattern this time.
    Let's compare our solutions than, shall we?
    SELECT NVL(LENGTH(REGEXP_REPLACE('Having  fun  with  regular  expressions.  !',
                                     '([a-z])+|.', '\1', 1, 0, 'i')), 0)
      FROM dual;This time I don't use a backreference, the "+" operator (remember? 1 or more) will suffice. And since I want to count the occurences, not the letters, I moved the "+" meta character outside of the subexpression. The "|." trick again proved to be useful.
    Case insensitive search does have its merits. It will only search but not transform the any found substring. If I want, for example, extract any occurence of the word fun, I'll just use the "i" match parameter and get this substring, whether it's written as "Fun", "FUN" or "fun". Can be very useful if you're looking for example for names of customers, streets, etc.
    Enough about counting, how about finding? What if I want to know the last occurence of a certain character or string, for example the postition of the last space in this string "Where is the last space?"?
    Addendum: Thanks to another forum member, I should mention that using the INSTR function can do a reverse search by itself.[i]
    WITH t AS (SELECT 'Where is the last space?' col1
                 FROM dual)
    SELECT INSTR(col1, ' ', -1)
      FROM DUAL;Now regular expressions are powerful, but there is no parameter that allows us to reverse the search direction. However, remembering that we have the "$" meta character that means (until the) end of string, all I have to do is use a search pattern that looks for a combination of space and non-space characters including the end of a string. Now compare the REGEXP_INSTR function to the previous solution:
    SELECT REGEXP_INSTR(t.col1, ' [^ ]*$')                       
      FROM t;So in this case, it'll remain a matter of taste what you want to use. If the search pattern has to look for the last occurrence of another regular expression, this is the way to solve such a requirement.
    One more thing about backreferences. They can be used for a sort of primitive "string swapping". If for example you have to transform column values like swapping first and last name, backreferenc is your friend. Here's an example:
    SELECT REGEXP_REPLACE('John Doe', '^(.*) (.*)$', '\2, \1')
      FROM dual
      ;What about middle names, for example 'John J. Doe'? Look for yourself, it still works.
    You can even use that for strings with delimiters, for example reversing delimited "fields" like in this string '10~20~30~40~50' into '50~40~30~20~10'. Using REVERSE, I would get '05~04~03~02~01', so there has to be another way. Using backreferences however is limited to 9 subexpressions, which limits the following solution a bit, if you need to process strings with more than 9 fields. If you want, you can think this example through and see if your solution matches mine.
    SELECT REGEXP_REPLACE('10~20~30~40~50',
                          '^(.*)~(.*)~(.*)~(.*)~(.*)$',
                          '\5~\4~\3~\2~\1'
      FROM dual;After what you've learned so far, that wasn't too hard, was it? Enough for now ...
    Continued in Introduction to regular expressions ... last part..
    C.
    Fixed some typos and a flawed example ...
    cd

    Thank you very much C. Awaiting other parts.... keep going.
    One german typo :-)
    I'm replacing all characters except spaces mit anull string.I received a functional spec from my Dutch analyst in which it is written
    tnsnames voor EDWH:
    PCESCRD1 = (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
                                                   (HOST=blah.blah.blah.com)
                                                   (PORT=5227)))
               (CONNECT_DATA=(SID=pcescrd1)))
    db user: BW_I2_VIEWER  / BW_I2_VIEWER_SCRD1Had to look for translators.
    Cheers
    Sarma.

  • Help About Regular Expression.

    Hello,
    I am trying to parse string buffer by using Regular Expression.
    Suppose my string buffer is:
    Hi , How are you?
    Hello: abc
    hurrey : [ this is test msg
    Pls reply to this mail
    Hello: xyz
    Test1
    I want to search string: "Hello: anystring till end of line" which is
    not included in [].
    So In above example my Regular expression should only find
    first "Hello: abc".
    Is it possible by using Regular expression?

    Can we have Regular Expression which will get both "Hello: string"
    suppose my string buffer is:
    Hi , How are you?
    Hello: abc
    hurrey : [ this is test msg
    Pls reply to this mail
    Hello: xyz
    Test1
    happy: [ test2
    my test
    Hello: abc
    then result should be :
    Hello: abc
    [ this is test msg
    Pls reply to this mail
    Hello: xyz
    Test1
    [ test2
    my test
    Hello: abc
    ]

  • Regular expression or regex

    Hi all,
    can i use regular expression or regex in 4.7 r/3 sever.
    if yes then pls tell me how to use regex for differentsiate between table name and fieldname for dynamically select query like
    SELECT T000MTEXT AS A FROM T000 WHERE T000MANDT IN ( SELECT T000MANDT FROM T000 WHERE T000MWAER = 'DEM')
    or
    SELECT MARAMATNR AS A MAKTMAKTX AS B FROM MAKT INNER JOIN MARA ON MAKTMATNR = MARAMATNR WHERE MARAMATKL = '013' AND MAKTSPRAS = 'E'
    or many.
    regards

    Got myself.
    RegEx or Regular Expressions is only supported in NetWeaver 7.0.

  • Regular expression for Period

    i want to write a regular expression which would allow any printable ascii but not period (.). how would this expression look like...anyone ??

    [\p{Print}&&[^.]] That's the intersection
    of the sets "all printable ASCII characters" and
    "everything but the period".:-) Once more showing my lack of knowledge!

  • Regular expression usage question

    Hi there.
    I have a 200 bytes EBCDIC variable record which I need to break down into fields. Fields are positional and are either text, binary numbers, packed-decimal and 64bytes long numbers.
    My question is. Can regular expression handle this complex data.
    I want to isolate each field into their corresponding format. EBCDIC into ASCII text, binary into java Integer and so on.
    The reason for using reqular expression is because the record format could change and regular expression would be easier to modify without having to change the code.
    Your words of advice are highly appreciated.
    Please advice.
    Regards,
    Ulises

    Regular expressions? I don't think so.
    If you have a situation where positions 1-3 might be a binary number like client number, and the format might change so it moves to positions 12-14, then you could certainly write a record-format class to encapsulate that sort of information. In fact that would be a very good idea. But I can't imagine how a regular expression would help in getting a number out of three bytes, for example.

  • [CC] Search&Replace: Bug only with Regular Expressions

    Can you confirm the following behaviour/bug?
    Steps to reproduce:
    1 Create a new document in DW CC
    2 Enter that text in the source code view:
    <p>&euro;</p>
    3 Open Search&Replace
    Field Search in: Current document
    Field Search: Text
    Field Search (3rd Field): €
    Start Search
    Result: As expected the "€" is found.
    4 [x] Regular Expressions
    Start Search
    Result: "€" isn't found
    Can you reproduce that?
    Do you regard that as a bug like me?
    If not, why please?
    Do you think it is technically impossible for the developers to solve the task?
    Do you think the developers forgot to gray out "text" in the choice box and allow regular expressions only in source code?
    Thanks.

    Nice that you like the nick
    Sure, I know that I can file a feature wish.
    But my main interest in this forum is to know, what other users think about certain features, why they think so, which they miss, which they regard as a bug, ...
    When I remember it right, you told me some time ago, that you don't use RegEx.
    Than I understand, that everything around that feature is not important for you.
    What I like to understand is, why you think the behaviour is logically.
    For me it is the opposite.
    You get a result with "Scope: Text", "[ ]RegEx".
    And you get no result with "Scope: Text", "[x]RegEx".
    Incredible strange.
    I would appreciate, if you could explain more detailed your view.

  • Allow specific characters - Regular Expression

    Hello everyone
    I am new to regular expression and I have a very simple question. I use the "read from text file" function to load a Tab delimited file with 3 columns into my VI. Next, the string is converted in array and I use the values.
    Nevertheless, I want to develop a "filter" allowing only digits (0-9), colon, comma and point into strings.
    Using the "match regular expression" function, I was trying a regular expression like that:
    [^0-9]|[^\].[|^:]|[^,]
    But it is not working.
    Could someone help me with this issue?
    Thanks
    Dan07
    Solved!
    Go to Solution.

    Hello
    Actually I don't need to modify the string that has "invalid" characters, I just need to identify them instead. Find below a VI testing both methods: Match Regular Expression and Search and Replace String.
    Using Match Regular Expression method, I got correct results since all the "valid" values must be identified as "-1" and all the "invalid" values must be identified as positive numbers (offset).
    Nevertheless, using Search and Replace String method I got wrong results, since all the strings were classified as "valid" (-1), but "bg" and "03/12/2010" are not "valid".
    I will go ahead with Match Regular Expression method because it is working great, but I was just wondering how to fix Search and Replace String method to achieve equivalent results.
    Thanks
    Dan07
    Attachments:
    Regular Expression_example.vi ‏18 KB

  • Spliting a large string using regular expression which contain special char

    I have huge sting(xml) containing normal character a-z,A-Z and 0-9 as well as special char( <,>,?,&,',",;,/ etc.)
    I need to split this sting where it ends with </document>
    for e.g.
    Original String:
    <document>
    <item>sdf</item>
    <item><text>sd</text</item>
    </document>
    <document>hi</document>
    The above sting has to be splited in to two parts since it is having two document tag.
    Can any body help me to resolve this issue. I can use StringTokenizer,String split method or Regular expression api too.

    manas589 wrote:
    I used DOM and sax parser and got few exception. Again i don't have right to change xml. so i thought to go with RegularExpression or some other way where i can do my job.If the file actually comes in lines like what you posted, you should just be able to compare the contents of each line to see if it contains "</document>" or whatever you're looking for. I wouldn't use regex unless I needed another problem.
    I got excpetion like: Caused by: org.xml.sax.SAXParseException: The entity "nbsp" was referenced, but not declared.
         at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
         at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
         at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)So then it isn't even XML.
    Edit: sorry, I just realized why you're considering all of these heavy-duty ideas. It's just that you don't know how to break the string into lines. You do it like this:
    BufferedReader  br = new BufferedReader(new StringReader(theNotXMLString));

  • Field validation regular expression to accept only numbers

    Hello.
    I would like to have a field validation regular expression to accept only numbers - no characters. The list of pre-packaged regular expressions that are included with ApEx does not contain this and I am not a very good regular expression writer. Can anyone help?
    Thanks!
    Boris

    Under the Regular Expression validation all you need to have is:
    ^[[:digit:]]$For the email address it just depends how detailed you want it:
    ^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$or...
    [\w-]+@([\w-]+\.)+[\w-]+Hope these help
    Edited by: MikesHotRod on Sep 3, 2008 12:40 PM

  • Regular Expression - find double hyphens only

    I am wondering if there's a way to write a regular expression to find double hyphens and change them to single hyphens.  The catch is that some of the text I'm searching through have multiple hyphens.
    Example:
    str1 = "Here is my sample text with double -- and I would like to replace this with one hyphen."
    str2 = "Here is another sample with multiple hyphens ----- that I do not want to change but leave as is."
    Is there a way to change only str1 to a single hyphen and keep str2 as is?

    You are correct.  I should have been more explict.  Here are some real examples.  I hope this helps.
    Helps what?
    Have you tried to write the regex yourself, at least?
    Adam

Maybe you are looking for

  • Email no longer working

    Not sure i this is already posted but im no longer able to recieve emails through outlook no settings have changed but its rejecting my user and pass. have tried logging into my email through bt but it tells me to change the password due to "unusual

  • Sound pressure spectra with SVT

    Hey all, I have a project which I have been having a bit of trouble implementing. I'm performing several measurements at 48kHz/24Bit of some sound events. My requirement are as follows for sound pressure spectra analysis.  500 - 20 kHz frequency band

  • Replace timeline and keep existing chapter playlists

    I have already authored my project and set up all the existing Chapter playlists on Time line A. however, i noticed a mistake and had to re edit the timeline as it has been imported from premiere as one continuous file. I wish to re import it as time

  • Can't login after 10.5.6 upgrade

    Yesterday I upgraded my iMac 2 GHz to OS 10.5.6. It worked fine in the beginning, but today the Mac started to behave slow and strange (couldn't click on anything). I had to force quit. But then I couldn't login again. When the login window appears,

  • Displaying Entity Level Attributes on Summary screen

    Hi Is there a way to show the value of an entity level attribute on the summary screen? I need the attribute values for all entity instances to be listed on the summary screen. For example, I have a household member entity and I need to display on th