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)

Similar Messages

  • 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

  • Conversion of a floating point type field

    Hi,
    I'm fetching field ATFLV from table AUSP for a particular value of ATINN.ATFLV is a floating point type field.
    Can anyone please guide me as to how to convert this field(ATFLV) from floating point no. to a simple no.?
    Helpful answers will be rewarded.
    Regards,
    Sipra

    hi,
    Do like this,
    float f = 234.33;
    int i = (int) f; // i has value 234.
    reward points if helpful..

  • Settings for inspection point user field

    Hai gurus,
    i want to know the settings for inspection point user field(150)
    1) Field combination = 150
    2 )Inspection type = ?
    3) Functional location- field active  = ?(predefined field)
    under user field
    1)Text length 18 - Field active = ?
    2)Text length 10 - Field active = ?
    3)Number  length 10 - Field active = ?
    4)Number length  3 - Field active = ?
    5) Date - Field active = ?
    6) Time - FIeld active = ?
    waiting for positive reply.
    regards,
    sekar chand

    dear Sekar
    1) 150 inspection point is maily used for production related inspection. 03 , 04 . it is a freely defined inspection point which means you want to carry out several inspections for each operation during the production process
    2) It is not Inspection type it is inspection point type- There are mainly 3 inspection point type
    Freely defined - explained
    Equipment related - You need this inspection point type if you want to carry out calibration inspections and record the results of test equipment inspections or inspections of functional locations
    Inspection points to identify samples-You need this inspection point type if you want to manage samples and record inspection results for physical samples
    3) Predefined field is for identification of the inspection point.
    Example for inspection point type  1
    For inspection point type 1 (inspection point for equipment) that is used, for example, in a calibration inspection, the equipment number must be entered. (To access the results recording function, however, you can use a different key word instead of 'equipment number', such as, 'test equipment').
    Example for point 3
    The sample-drawing procedure determines the number of samples to be taken. The system automatically creates an inspection point for each sample.
    4) User fields are again identification. You can add in key work text which will appear while result recording.
    5) Field Active  -This helps in sorting out the user fields.  An identification field is only active if you have made an entry in this field.Fields with numeric entries are required fields. The numbering sequence that you define for these fields uniquely identify an inspection point.
    a typical example can be User field/field active/keyword combination
    1)Text length 18 -1 -Inspector Name
    2)Text length 10 - 2- Location
    3)Number length 10 - 3- Shift No
    4)Number length 3 - 4- Section No
    5) Date - 5- Date
    6) Time - 6-  Time
    please Date and Time populates automaticaly. it is not mandatory that you use all the fields
    Hope this helps
    Regards
    gajesh

  • Wat should be the regular expression for string MT940_UB_*.txt to be used in SFTP sender channel in PI 7.31 ??

    Hi All,
    What should be the regular expression for string MT940_UB_*.txt and MT940_MB_*.txt to be used as filename inSFTP sender channel in PI 7.31 ??
    If any one has any idea on this please let me know.
    Thanks
    Neha

    Hi All,
    None of the file names suggested is working.
    I have tried using - MT940_MB_*\.txt , MT940_MB_*.*txt , MT940*.txt
    None of them is able to pick this filename - MT940_MB_20142204060823_1.txt
    Currently I am using generic regular expression which picks all .txt files. - ([^\s]+(\.(txt))$)
    Let me know ur suggestion on this.
    Thanks
    Neha Verma

  • Separator for floating point numbers

    Hello,
    I work with oracle 9 and have a problem with the entry of floating point numbers.
    The separator for floating point numbers in my data is a point (5.60).
    The pre-setting of oracle is a comma (5,60).
    By inserting I get the error message:
    01722. 00000 - "invalid number"
    How can i change this setting
    Thanks for Help
    F.

    Hi,
    I'm not sure if I understood your problem, however the NLS_NUMERIC_CHARACTERS variable specifies the characters to use as the group separator and decimal character.
    SQL> create table t1 (val number);
    Table created.
    SQL> select * from nls_session_parameters;
    PARAMETER                      VALUE
    NLS_LANGUAGE                   AMERICAN
    NLS_TERRITORY                  BRAZIL
    NLS_CURRENCY                   R$
    NLS_ISO_CURRENCY               BRAZIL
    NLS_NUMERIC_CHARACTERS ,.
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD/MM/YYYY
    NLS_DATE_LANGUAGE              AMERICAN
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH24:MI:SSXFF
    NLS_TIMESTAMP_FORMAT           DD/MM/RR HH24:MI:SSXFF
    NLS_TIME_TZ_FORMAT             HH24:MI:SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD/MM/RR HH24:MI:SSXFF TZR
    NLS_DUAL_CURRENCY              Cr$
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    17 rows selected.
    SQL> insert into t1 values (1.50);
    1 row created.
    SQL> select * from t1;
           VAL
           1,5
    SQL> alter session set nls_numeric_characters='.,';
    Session altered.
    SQL> select * from t1;
           VAL
           1.5Cheers
    Legatti

  • How to form a regular expression for matching the xml tag?

    hi i wanted to find the and match the xml tag for that i required to write the regex.
    for exmple i have a string[] str={"<data>abc</data>"};
    i want this string has to be splitted like this <data>, abc and </data>. so that i can read the splitted string value.
    the above is for a small excercise but the tagname and value can be of combination of chars/digits/spl symbols like wise.
    so please help me to write the regular expression for the above requirement

    your suggestion is most appreciable if u can give the startup like how to do this. which parser is to be used and stuff like that

  • Using regular expressions for validation in i18n

    Can we use regular expressions for validation of inputs in a java application taking care of i18N aspects too. Zip code for different locales are different. Can we use regular expressions to validate zipcode inputs from different locales

    hi,
    For that shall i have to create individual patterns for matching the inputs from different locales or a single pattern will do in the case of validating phone nos. around the world, zip codes etc. In case different patterns are required, programmer should have a konwledge of difference in patters for different locales.
    regards
    sdas

  • F suffix for floating point.

    Okay, I'm a proficient c++ programmer and have been learning Java for only a few weeks now.
    I have a question about the f suffix for floating point varibles such as float f = 3.14f;
    The f suffix casts this as float right? which is the same as float f = (float) 3.14; Correct?
    Why do we have to add the f suffix in the first place? Doesn't the compiler know that we want a float and not a double? (single-precision 32-bit instead of double precision 64 bit) I really do not understand the concept here or why they need the f suffix.
    Can someone explain?

    ThePHPGuy wrote:
    The f suffix denotes that the literal is of a floating-point type.Yes. The d suffix does the same.
    Java has two different types of floating-point numbers.Right.
    The type double is the default type.Right.
    The float type can have a double and a float literal. Is this true or false?No. At least not in any way I understand it.
    I think you're confusing two things:
    "floating point number" is any number in the IEEE floating point format.
    "float" is a datatype holding a 32bit floating point number.
    "double" is a datatype holding a 64bit floating point number.
    floating point number literals can be either double literals (without suffix or if the "d" suffix is used) or float literals (when the "f" suffix is used).

  • Regular Expression for a Person's Name

    Hi,
    I am using the org.apache.regexp package and trying to find the regular expression for a person's name. It allows only the alphabetic string.
    I tried [a-zA-Z]+. But this also accepts the thing like "BUSH88", which is not what I want...
    Can anybody help me figure this out?
    Thanks in advance,
    Tong

    Hi,
    I am using the org.apache.regexp package and trying to
    find the regular expression for a person's name. It
    allows only the alphabetic string.
    I tried [a-zA-Z]+. But this also accepts the thing
    like "BUSH88", which is not what I want...
    Can anybody help me figure this out?
    Thanks in advance,
    Tongtry this:
    ^[a-zA-Z]+$
    the ^ represents the start of the String and the $ represents the end.
    So the expression is saying: "between the beginning and the end of the String there will only be alphbetical characters"

  • How to write the regular expression for Square brackets?

    Hi,
    I want regular expression for the [] ‘Square brackets’.
    I have tried to insert in the below code but the expression not validate the [] square brackets.
    If anyone knows please help me how to write the regular expression for ‘[]’ Square brackets.
    private static final Pattern DESC_PATTERN = Pattern.compile("({1}[a-zA-Z])" +"([a-zA-Z0-9\\s.,_():}{/&#-]+)$");Thanks
    Raghav

    Since square brackets are meta characters in regex they need to be escaped when they need to be used as regular characters so prefix them with \\ (the escape character).

  • Regular Expression for /, \, #, -, & ‘

    Hi,
    Can anybody tell me the regular expression for provided characters.
    Code is preferable.
    Thanks in advance.

    "[-/\\\\#&']"

  • What is the regular expression for the end of a story?

    Forgive me if this is wrong forum for asking this, but I'm trying to use the Find command using GREP and I need to know the regular expression for the end of a story. (Or, the last character of a story.) Thanks in advance.

    I'd try search for .\z (that's a dot in front) which ought to find the very last character in the story, and replace with $0 and your additional text.
    You know you can use a keyboard shortcut to move your cursor to the end of any story, right? Ctrl + End on Windows, Cmd + End, I think, on Mac. Unless you want to do this to every single story in the document, I would think you might be just as well off to put your text on the clipboard, put the cursor in the story and hit the key combo followed by Ctrl/Cmd + V to paste.

  • Regular Expression For Dreamweaver

    I still haven't had the time to really become a professional when it comes to regular expressions, and sadly I am in need of one an finding it difficult to wrap my head around.
    In a text file I have hundreds of instances like the following:
    {Click here to visit my website}{http://www.adobe.com/}
    I need a regular expression for Dreamweaver that I can run within the "Find and Replace" window to switch the order of the above elements to:
    {http://www.adobe.com/}{Click here to visit my website}
    Can anyone provide some guidance? I'm coming up short due to my lack of experience with regular expressions.
    Thank you in advance!

    So you have a string that starts { and goes until the first }.  Then you have another string exactly the same.  And you want to swap them.  I'm not making any assumption that the second one has to look like a URL (that's a whole other minefield, but perhaps you could do something simple like it must start with http). 
    You don't specify how your text file is divided up, have you got this as a complete line to itself, or is it just  a huge block of text?  Preferably as individual lines.
    I don't have Dreamweaver, but this worked for me in Notepad++
    Find: ^{(.*?)}{(.*?)}$
    Replace with: {\2}{\1}
    My file looked like this:
    {Click here to visit my website}{http://www.adobe.com/}
    {some other site}{http://www.example.com/foo}
    And doing a Replace All ended up like this:
    {http://www.adobe.com/}{Click here to visit my website}
    {http://www.example.com/foo}{some other site}

  • Regular expression for LOV?

    I have a list of strings in an LOV. I tried filtering it by typing in "^disk" in the search bar, which I hope will return a list of strings starting with "disk", but I failed.
    Any idea on how to use regular expression for LOVs? Thanks!

    HI Buffalo,
    i have a select list item in my page1 named :P1_EMPNAME with lov query value
    select ename as d, ename as r from emp WHERE EGEXP_LIKE(ename,:P1_SEARCH) or :P1_SEARCH IS NULL
    i have a Search text box in my page1 name :P1_SEARCH
    When i run the page, by default all the empnames will display in the lov list item
    i have given ^buffalo in the text seach item and clicked the submit button ,it shows the Employee buffalo in my list item lov.
    If you want all the entries that start with S, search for ^s
    End with R, use r$
    please try this link http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28424/adfns_regexp.htm
    Thanks
    Logaa

Maybe you are looking for

  • Lost Playlist info

    I recently had to replace the logic board on my Powerbook G4 and have been reinstalling my iTunes library from my external harddrive. Everything has reinstalled except my Beatles music. The individual songs show up but not as separate albums. Any ide

  • Yahoo Webmail Blue Progress Bar Freezes adding attachments

    Using Mac OS X, Leopard 10.5.6 and Apple Safari 3.2.1. There is a bug when using Apple Safari with Yahoo Webmail. Whenever you attach a file (while composing a message), the blue progress bar (fills in behind the website address window) freezes. Ever

  • Can you stream video to a PB?

    I just got a PB - is there a way to stream video to a PB the way that you can with an iPad using Air Video?  Either on your LAN or over the net?

  • OS X 10.4.6

    I have a new macbook and it came with the OS X installation CD's incase you ever need to reinstall the OS... anyway my cuz has an old emac and wants tiger OS so can she use my CD's to update her system w/out having to pay for it?

  • Layout Modifications in HTMLDB Page

    Hi, I have a couple of queries. 1. How can i remove the ( Edit Application | Edit Page 6 | Create | Session | Debug | Hide Edit Links | Show Edit Links ) which appears at the bottom region of a page. I am using the 'printer friently' as the page temp