Pattern matching for range of numbers

I am facing problem in using a pattern like [200-300] to match any number in the range 200 and 300 inclusive. I wrote following code:
public class RangeTest {
     public static void main(String[] args) {
          String pat = "[100-200]";
          String input = "100";
          // incpat.replace("[", "\\[");
          // incpat.replace("]", "\\]");                    
          System.out.println("Pattern" + pat);
          Pattern pattern = Pattern.compile(pat);
          Matcher matcher = pattern.matcher(input);
          if (matcher.matches()) {
               System.out.println("EPC Matched:" + input + " and pattern:"              +matcher.pattern());                         
}and tested it for different values of input , it's not working. I tried even giving escape characters for "[" and "]" (commented code). Can i use pattern matching in this case.
Please help me.
Regards,
Prashanth

I am facing problem in using a pattern like[200-300] to match any number in
the range 200 and 300 inclusive.Try this one: "(2\d\d)|(300)".
kind regards,
Jos
ps. Waiting for Sabre to jump in telling me that the
parentheses aren't needed ;-)The parentheses aren't needed Jos! :-)

Similar Messages

  • Pattern matching for an expression

    How do I do a pattern matching for a strings that look like the ones below?
    11 1
    12 12
    1 34
    Thanks

    >
    "[^[0-9]|^RATE]";
    "[\\d\\d\\d\\d\\d\\d\\d|\\w\\w\\w\\w\\w\\w\\p{Punct}\\w
    \w\\p{Punct}\\w|[RATE]]";
    I have the above two patterns to match. I want to
    combine these two and say this and that. How do I use
    an and in between. I tried the following and it didn't
    work.
    "[^[0-9]|^RATE][\\d\\d\\d\\d\\d\\d\\d|\\w\\w\\w\\w\\w\\
    \\p{Punct}\\w\\w\\p{Punct}\\w|[RATE]]";
    Any help?I think you'd do better to give us examples of the text you're trying to match, because none of those patterns makes any sense.

  • Pattern Matching for a wildcard Ip address

    I m working on a project. And in it i get problem for pattern matching.I have ipv4 ip address for ex " 127.3.0.1* ".I have to generate regular exp for pattern matching in Java.Can you guide me what can be its regular exp.
    thanks,
    preeti

    preetiGupta wrote:
    I m working on a project. And in it i get problem for pattern matching.I have ipv4 ip address for ex " 127.3.0.1* ".I have to generate regular exp for pattern matching in Java.Can you guide me what can be its regular exp.Alternatively, [try this|http://lmgtfy.com/?q=regex+for+ipv4+addresses].
    Winston

  • Pattern matching for LCD function test

    Hello,
    I am writing a VI that is taking a single picture from a camera and then compares it with a template extracted before that.
    The camera is looking at LCD display and and the purpose of the matching is to find whether there is a dead pixel or sth wrong at the display. The problem is that the comparison doesn't work as expected.
    I will illustrate this with just one examples with picture attached:
    - At step 1. the template is created. (you can see RUN 2 at the top left corner at the display) 
    - At step 2. pattern matching is performed with the same mode of the LCD but a little bit tilted(score - 972 achieved)
    - At step 3. the mode is changed (you can see RUN 3 at the top left corner at the display, everything else is the same) - but however a bigger score of 974 is achieved
    Any explanation of this and some suggestions that can improve my program !?
    Thanks a lot
    Iliya G. 
    Attachments:
    1step.JPG ‏43 KB
    2step.JPG ‏42 KB
    3step.JPG ‏38 KB

    Hi David,
    I went through this OCR examples that you mentioned but in fact I find them very annoying because in many cases the output string depends on how you draw your ROI. Please, find an example below and could you please tell me if i am doing sth wrong, but in fact i don't think so.
    When I try to read the characters separetely, everythings goes ok - it finds r,u,n and 1.
    But when I make the ROI bigger in order to contain all the characters, the output is the one at the picture. Any ideas?
    Thanks,
    Iliya 
    Attachments:
    1.JPG ‏21 KB

  • CEP Pattern Matching for Straight line graph

    Hi,
    I have a scenario where weight is directly proportional to depth, which produces a linear straight line.
    CEP will get data for weight and depth, CQL has to be write to raise an event when there is a change in straight line graph.
    How to write CQL query and use match pattern for this.
    Thanks,
    Sri

    So lets say you have an input Channel with event Type E(weight, depth)
    Idea is to compute the slope - weight/depth and report the first and those subsequent events whose w/d is different from that of the previous event
    Here is the query
    SELECT
              T.weight,
              T.depth
    FROM
              E MATCH_RECOGNIZE (
                    MEASURES
                             A.depth as depth,
                             A.weight as weight
                    PATTERN (A)
                    DEFINE
                             A AS ( (PREV(A.weight) is null) OR (PREV(A.weight)/PREV(A.depth) != A.weight/A.depth) )           
              ) as TEdited by: Anand Srinivasan on Mar 8, 2012 7:56 AM

  • Pattern matching for thumb print scanner using java

    I want to get some information about security system technology using java to develop my final year project. Please kindly assist me in searching some related information regarding thumb print scanner security system. Anyone who can help me in this, i will really appreciate it, thank you in advanced !

    This is going to be a tough project. Here are a couple of ideas
    1. Java, or whatever language you do it in probably won't matter that much.
    2. You need to find algorithms for matching fingerprints. There are probably some out there... You may need to pay to use them. There are also probably some books out that might help you figure out how to do this, or how other people have done this, or who to contact about doing this.
    3. Partnering up with someone, either in industry (like IBM maybe) or at the very least a professor is going to be important.
    4. Don't try to invent the wheel. Do your research and reuse as much as you can. Getting the algorithm + the scanner are going to be the hard parts

  • Oracle OpenSSO Pattern Matching for Application Express "Free" Pages

    Has anyone successfully established a "Free" page within an Application Express application under Oracle's OpenSSO? The problem seems to be associated with the use of wildcards and the f?p syntax. In addition, the use of wildcards and multi-level wildcards in the OpenSSO un-enforced policy list seems to drop semi-colons from the posted URLs. We have successfully deployed applications which require authentication, but applications which contain a "free" landing page elude me.
    Any insight would be appreciated.
    Thank you.

    Has anyone successfully established a "Free" page within an Application Express application under Oracle's OpenSSO? The problem seems to be associated with the use of wildcards and the f?p syntax. In addition, the use of wildcards and multi-level wildcards in the OpenSSO un-enforced policy list seems to drop semi-colons from the posted URLs. We have successfully deployed applications which require authentication, but applications which contain a "free" landing page elude me.
    Any insight would be appreciated.
    Thank you.

  • How to implement pattern matching in RFC input paramenter?

    Dear Friend.......
    I have a requirment for implement a pattern match for name field of vendor in one of RFC.........
    For ex..........
    Name field:-  A* -> give all list of name  starting with a.
    how can we implement this?
    Any way............Suggest me
    Regards
    Ricky

    Hi,
    I am not using any ABAP program for calling this RFC,I am using Webdynpro for this one.
    so how it possible to implemnet same things at there.
    Regards
    ricky

  • A regular expressin problem: String.matches & the pair of Pattern & Matcher

    I observe this problem when working on pattern match for Z5Z-5Z5, Z5Z 5Z5 or Z5Z5Z5.
    When I use the match method of the String class, the correct pattern will yield true with
    !str.matches("^[A-Za-z]\\d[A-Za-z]\\s?|-?\\d[A-Za-z]\\d$").
    When I use the pair classes of regex:
    Pattern p = Pattern.compile("^[A-Za-z]\\d[A-Za-z]\\s?|-?\\d[A-Za-z]\\d$");
    Matcher m = p.matcher(str);
    a string of "v7u h4e" (two blank spaces in between) can pass the !m.find().
    Have anyone else experienced the same situation?
    Do I use them right, or bugs?
    Thanks for your input.
    v.

    This is why I wish regex references would list the
    operator precedence. What do you mean? My regex reference does show that right under the section called "Operators" in the second chapter.
    Maybe you need to update your references and buy "Programming Perl"? :)
    I think there are only three
    levels of precedence, but it needs to be crystal clear
    that | has the lowest precedence (even lower than
    putting two tokens together!) and often needs
    parentheses: "\w\d|\s\w" means "(\w\d)|(\s\w)", not
    "\w(\d|\s)\w".Actually for that particular operator it is pretty consistent. It is always very low. Even when I was introduced to the theory of regex's in school the precedence was lower than everything else.

  • Vision assistant steps to be followed for pattern matching

    I am acquiring color images of hands movement using web camera of laptop.
    I want to process the acquired images to use for pattern matching.
    What are the steps to be followed to achieve the above mentioned task.

    In the following we proceed to function block search pattern extracted in the previous process (the parameters as rotation angle and minimum score is inserted into SETTINGS control), extract the output of the search function to get the position values indicators that will be displayed on the front panel)
    Atom
    Certified LabVIEW Associate Developer

  • How do you create the equivalent of a named  range in Numbers for iPad?

    At first I didn't think Numbers could handle named ranges but when I look at the formula written for the "Personal Budget Template"  The "Actuals" column is calculating using named ranges but I am not sure how the ranges were created...  In any case it does appear that there is a way.  Does anyone know how?

    Those technically are not named ranges. Its using the information in the "header" rows. Once you make a row a header row and sum it (or include the whole colun in some function). It will use the data/name in the header row in the equation to make it clearer. I do not think you can make named ranges in Numbers.
    I made a test excel workbook using two formulas to sum a range, one with named ranges one without and sent to my ipad, when i opened it up...and downloading... yep...  it converted the named range to a regular range with letters and numbers. no named ranges support.
    But learn to use your header and footer rows to get the same affect in many functions.
    When i assign both header rows and columns to a table, it combines them into one string to show "Jan 2001" when I had a header column with Jan in A2, and a header row with "2001" in B1, then used the value in an equation.
    The one your looking at I think says something like "=Sum(actuals)". that formula is in a designated footer row, and has a designated header row. at the top of that column is the label "actual". if you look at the difference column formulas, you will see how it combined header rows and columns into a single text string and use it to cross reference the cell being used.
    Jason

  • How can I define a non-rectangular (eg. circular) ROI for pattern matching using IMAQ?

    I would like to create regions of interest that are not rectangular using IMAQ Vision Builder. Including polygons, circles, etc. I am using version 5.0.
    Thank you.

    Hello,
    The current pattern matching algorithm requires a rectangular ROI. See the IMAQ Vision Concepts manual for detailed info on how the algorithm works.
    Regards,
    Yusuf C.
    Applications Engineering
    National Instruments

  • Latin 1 supplement for Pattern matching

    Hi All,
    I am trying to pattern match a string with the following pattern:
    "\\p{InLatin1Supplement}+"(want to allow only characters in Latin 1 Supplement charset)
    However I get java.util.regex.PatternSyntaxException: Unknown character family {Latin1Supplement}Please suggest what should be the proper string for the pattern.
    Thank you !!

    Hm, have your checked Blocks-3.txt, as it says in the javadocs?
    "Unicode blocks and categories are written with the \p and \P constructs as in Perl. \p{prop} matches if the input has the property prop, while \P{prop} does not match if the input has that property. Blocks are specified with the prefix In, as in InMongolian. Categories may be specified with the optional prefix Is: Both \p{L} and \p{IsL} denote the category of Unicode letters. Blocks and categories can be used both inside and outside of a character class.
    The supported blocks and categories are those of The Unicode Standard, Version 3.0. The block names are those defined in Chapter 14 and in the file Blocks-3.txt of the Unicode Character Database except that the spaces are removed; "Basic Latin", for example, becomes "BasicLatin". The category names are those defined in table 4-5 of the Standard (p. 88), both normative and informative."
    Other than that, I don't know, sorry.

  • Can I use differnet patterns for a "digital pattern match start trigger"

    Hello,
    Currently I would like use different patterns for a trigger the PCIe-6537 board to start capture data, for example, two patterns: 1101 and 1100 in digital IO lines line0:3, whenever one of this two pattern happens, start capture.
    It seems like "digital pattern match" in DAQmx trigger can use one pattern only.
    thanks!

    Hi tt_ni,
    Pattern I/O only allows the acquisition
    based off of one pattern. This is a “limitation” of the hardware based on the
    registers being set a certain way and monitoring a change from that. You could
    add external circuitry to OR your patterns and based the pattern I/O off of the
    output of that external circuitry. The other option is to look at an FPGA
    option.
    Mark E.
    Precision DC Product Support Engineer
    National Instruments
    Digital Multimeters (DMMs) and LCR Meters
    Programmable Power Supplies and Source Measure Units

  • Multiple ROIs for Pattern matching

    I want to define multiple regions of interest for pattern matching so that if one fails an alternative ROI might be used.The acquistion is continuous. I have a system that works with single ROI. I want to use the same with multiple ROI.

    Are you looking for the following examples?
    http://sine.ni.com/apps/we/niepd_web_display.displ​ay_epd4?p_guid=B45EACE3E07356A4E034080020E74861&p_​node=DZ52500&p_source=external
    http://sine.ni.com/apps/we/niepd_web_display.displ​ay_epd4?p_guid=B45EACE3E8E356A4E034080020E74861&p_​node=DZ52505&p_source=external
    Hope it helps.

Maybe you are looking for

  • To pass non key field data to workflow

    Hello, I want to pass data from webdynpro application to workflow. For this i used FM 'SWE_CREATE_EVENT' to trigger the workflow. I filled the container table with following values wa_cont-element = 'NAME2' wa_cont-value = 'James Anderson'. APPEND wa

  • JSP Precompile - Doesnt Work

    Hi All,           I am having serious trouble trying to precompile my JSP's and have the wl           server recognise them (and not re-compile them for me). Im using WLS6.1 with           SP2 installed.           I am running the JSPC pre-compiler w

  • I used the migration assistant....PC to MAC and I can't find what I transferred on the MAC

    Hello, I'm new to the MAC.  I used the migration assistant....PC to MAC and I can't find what I transferred on the MAC

  • Numbers fonctions en français

    Beaucoup de fonctions ne donnent pas de résultats corrects et affichent un triangle rouge avec mention " erreur de syntaxe. Ex =ALÉAT.ENTRE(10; 100). Est-ce un problème de localisation?

  • How to make radio button by key in webdynpro

    Hi,   I am new to dynpro. I created a UI element RADIOBUTTON GROUP BY KEY. I bound the SELECTEDKEY property of it to the attribute of string type. Now in my WDDOINIT , i need to fill the values in the attribute right??? . So shall i use SET_ATTRIBUTE