Problem in pattern matching

I am trying to validate a string having a proper user's name as:
santosh tripathi
rahul shekh
tarun bhatnagar
I have used this code snippet:
   public void validateName(String name)throws ValidatorException{
        Pattern isString = Pattern.compile("[a-zA-Z]"); 
        Matcher m = isString.matcher(name);
        if (name != null) {           
          if (name.length() < 3) {              
                throw new ValidatorException("Name should be at least 3 characters long.");
          else{                            
              if(m.matches()== false){                 
                 throw new ValidatorException("Please enter you name properly");  
        } else {
            throw new ValidatorException("Please enter Name.");
    }   but this is not working properly. The expression m.matches() always return a false value whatever name is entered.
I think, there is problem with the pattern compiled at first line.
what would be the correct pattern for the names I have given above?

san_4u wrote:
the valid name must be like
tim robert
bob relsmeth
sofia sankari
..........What about "Josef Müller"?
Or "&#1601;&#1610;&#1602; &#1588;&#1575;&#1605;&#1610;"?
Or "James Tiberius Kirk"?
Or "Q"?
Are they valid names?

Similar Messages

  • Problem with Pattern Matching

    Hello,  I am using Vision Development Module 8.5 with VB6.   I need immediate help on coming up with a solution for an auto warranty return for incomplete "Fog Lamp" indicator symbol.  I use a match score minumum of 900, but the match score returns a 932.  I don't see how a score > 900 is returned for so much missing from this symbol.  I use this test in a high production line and am very concerned.  I attached a Vision Assistant 8.5 script and actual image from auto warranty return.  The *.png template used for comparison is also in zip file.
    Thanks
    Attachments:
    PatternMatchScrpt-FogLamp.scr ‏2 KB
    Images.zip ‏137 KB

    Golden Template does exist in 8.5, and that was my first idea too, however, after trying it, it might not be the best algorithm for it.
    Golden Template compare the contour of objects, and they don't produce very good result in the specific image because the symbols are relatively small and not contrasted enough once we look at the luminance plane (i.e. we can't perform a great contour extraction).
    What I tried and works decently is the looking at the identification score of the classification algorithm.
    The only drawback of this method is that the object needs to be whole (i.e you might need to do a little morphology to close the objects). But the identification score will be quite different on the partial fog lamp.
    Another tactic, which is similar to the previous one is to (mis)use the OCR algorithm to train the object and use the character verification function (i.e. define a perfect fog lamp image (character) as the reference character when you train the OCR engine.
    The algorithm will them return a verification score which will tell you how far or close the pattern under inspection is from the reference one defined in the OCR file. OCR is based on classification.
    After trying that on your image, the verification score is different enough and you could use that for making a decision, but the difference is not as marked as with using the identification score of the classification algorithm.
    Both algorithms are based on thresholding the image. One advantage of using the OCR is that you can tweak the min character spacing parameter to adjust the segmentation so that the symbol is considered one full object (as opposed to having to perform morphology to do it if you use the classification algorithm).
    As I mentioned, classification seems to give you a better differentiation between the scores.
    Both methods allow you to define a Classification file or Character Set File that allow you to test multiple symbols.
    I am attaching a couple inspections and files I used to do this quick test.
    Hope this helps.
    Best regards,
    Christophe
    Attachments:
    Fog Lamp Inspection.zip ‏156 KB

  • Problems with pattern matching Regular expression

    String emailRegEx = "(\\w+)@(\\w+\\.)(\\w+)(\\.\\w+)*";
    String test = "[email protected]";
    if(test.matches(emailRegEx)) {
    }throws an exception
    java.util.regex.PatternSyntaxException: Illegal repetition near index 5.

    It works fine for me.

  • Pattern Matching problems

    Hi people,
    I'm having a slight problem with pattern matching. What I need to do is find if my pattern is a given string an return the end index.
    Here's my string:
    <TD>Some text</TD>
    I need to find everything between the 2 anchor tags. (In this case "Some text"). The query string parameters are the only thing that can change.
    Here's what I've tried:
    Pattern pattern = Pattern.compile("<a href=\"/cgi-bin/dir/program.cgi?PARAM1=[0-9]&PARAM2=[0-9]*\"onmouseover=\"window.status='';return true;\">");
    Matcher matcher = pattern.matcher(myString);
    if ( matcher.find() ) {
       System.out.println(matcher.end());
       System.out.println(myString.substring(matcher.end(), myString.toLowerCase().indexOf("</a>",matcher.end())));               
    }Of course I've tried a lot of other things. I've also googled to try to find some examples but to no avail.
    Thanks for any help.

    Just change your Patterne. It will work. The '?' character is being considered as a pattern matching character, while you want it as it is. Use \\ before '?' character.
    Pattern pattern = Pattern.compile("<a href=\"/cgi-bin/dir/program.cgi\\?PARAM1=[0-9]&PARAM2=[0-9]*\"onmouseover=\"window.status='';return true;\">");
    Hope it helps.

  • 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

  • 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.

  • Pattern Matching find double quate problem

    Hi all,
    I have below coding:
                Boolean isFind = false;
                Pattern pQuate = Pattern.compile("^{[\"]}");
                Matcher mQuate = pQuate.matcher(groupTwo);
                if (mQuate.find())
                  System.out.println("Find Double Quate");
                  isFind=true;;
                }The groupTwo contain value either start with character or ", the groupTwo actually get from another pattern matching group(2) which convert for example {filename="apple"} or {filename=apple}.
    I need to check whether the string value is start with double quate or not.
    but my coding got error! How to solve this?
    rgds,
    bryan

    Hi i have a problem in regex find method ...
    when i hardcode the value everything works fine but when i take it form a file
    the regex fails.. plz let me what is the problem
    thanks in advance
    private int locRegExp(String regExpStr){ //check current with previous section whether feature changed
         // RtfSection section=null;
         int j=currentsect;
         try{
         // private static String regExpStr=regExpStr1;
         // String regExpStr=".+@.+\\.[a-z]+";
         for(;j<data.size();j++){
              Pattern pat1;
              pat1 = Pattern.compile((String)regExpStr);
              // System.out.println("reg exp "+regExpStr);
         //     pat = Pattern.compile(regExpStr.toLowerCase().trim());
         String content=((RtfSection)data.get(j)).content;
         if(content==null||content.trim().equals(""))
              continue;
         // System.out.println(content);
         Matcher matcher = pat1.matcher(content);
         //System.out.println(content);
         // matcher.reset(content);
         boolean result=matcher.find();
         //System.out.println("regex see "+result);
         if(result){
         System.out.println("Found the match "+matcher.group());
              break;
         }}catch(Exception e){
              System.out.println("am at regex "+e);
         return j;
         }

  • Problem while using color pattern matching

    Currently we are doing projects on real time object tracking where we found one doubt that irrespective of the object size whether this color pattern match works or not . My questions are as follows:
    1. Whether it is applicable for objects moving far . Because as it moves far, the size of the object decreases such that the color pattern matching is not working what will be solution since we must use color image
    2. What is the difference in using scale and  rotate invarient in color pattern matching
    3. How we can effectively decrease the ROI depending upon the object position as per below attached screen shots .
    we have removed boundary box values of X and Y coordinates at the four corner but we can't track as the object moves far away or we can't decrease the ROI as the object moves far.
    4. whether it is possible to see the value of particular pixel  in LABVIEW vision development module as we seen only the coordinate position . whether it is applicable to see particular pixel value. Guide us
    please, see the below screen shots and provide the solution how effectively decrease or increase  the ROI depending on objects position using color pattern match
    Attachments:
    problem in matching while object moves far.png ‏515 KB

    Hello,
    I have not been using the color pattern matching a lot (especially not in real-time). But since the pattern matching considers only small scale changes, you could try updating the color template every n-th iteration (depending on your setup and requirements). The major problem is the template size, since the color pattern matching tends to take quite a lot of time in learning the template. You would of course need to come up with some idea on how to change the subimage size, where the new template will be learned.
    This is the part of coarse (rough) object detection as was suggested by MoviJOHN. For example, if your object is distinctly red, you can extract the green channel from your rgb image and use threshold to roughly find the object and apply the new ROI - template.
    So:
    1. learn the template,
    2. use pattern matching with bounding rectangle (ROI) for the next couple of frames (you would need to experiment here where the detection fails -> how fast can you move the object away so that the detection fails),
    3. Before the detection fails -> rough object detection with some padded bounding rectangle (new ROI),
    4. Re-learn te template of new ROI and go back to 2.
    Again, the biggest issue is the template learning time - if you have a high resolution camera and the template is large, this won't satisfy your real-time application.
    You should set up the appropriate illumination first. The resolution is also important, since your object is moved back and forth (but the resolution will have a direct impact on the template learning time).
    Best regards,
    K
    https://decibel.ni.com/content/blogs/kl3m3n
    "Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."

  • Pattern match problem

    I have developed one application to explore pattern match.I have used CQL:
    SELECT mkt_evt.price FROM MktEvntInchannel MATCH_RECOGNIZE (MEASURES MktEvntInchannel.price AS price PATTERN( A B*?C) DEFINE A AS MktEvntInchannel.symbol="abcd", B AS MktEvntInchannel.symbol="pqr", C AS MktEvntInchannel.symbol="wet") AS mkt_evt
    But it is not showing any output.
    MarketEvent code:
    package com.bea.wlevs.example.algotrading.event;
    import javax.xml.bind.annotation.XmlRootElement;
    @XmlRootElement(name = "MarketEvent")
    public class MarketEvent {
         private Long eventTimeStamp;
         private String symbol;
         private Double price;
         private Long volume;
         private Long latencyTimestamp;
         private String text;
         * @return the latencyTimestamp
         public Long getLatencyTimestamp() {
              return latencyTimestamp;
         * @param latencyTimestamp the latencyTimestamp to set
         public void setLatencyTimestamp(Long latencyTimestamp) {
              this.latencyTimestamp = latencyTimestamp;
         * @return the timestamp
         public Long geteventTimeStamp() {
              return eventTimeStamp;
         * @param timestamp the timestamp to set
         public void seteventTimeStamp(Long eventTimeStamp) {
              this.eventTimeStamp = eventTimeStamp;
         * @return the symbol
         public String getSymbol() {
              return symbol;
         * @param symbol the symbol to set
         public void setSymbol(String symbol) {
              this.symbol = symbol;
         * @return the price
         public Double getPrice() {
              return price;
         * @param price the price to set
         public void setPrice(Double price) {
              this.price = price;
         * @return the volume
         public Long getVolume() {
              return volume;
         * @param volume the volume to set
         public void setVolume(Long volume) {
              this.volume = volume;
         public void setString_1(String text) {
              this.text = text;
              // TODO Auto-generated method stub
         public String getString_1() {
              // TODO Auto-generated method stub
              return text;
    }

    I have pushed these below data in jms queue from where my CEP application is reading.
    <?xml version="1.0" encoding="UTF-8"?>
         <MarketEvent>
         <eventTimeStamp>201100501</eventTimeStamp>
         <symbol>abcd</symbol>
         <price>3005.02</price>
         <volume>4657892</volume>
         <latencyTimestamp>201100501</latencyTimestamp>
         </MarketEvent>
    <?xml version="1.0" encoding="UTF-8"?>
         <MarketEvent>
         <eventTimeStamp>201100501</eventTimeStamp>
         <symbol>pqr</symbol>
         <price>3005.02</price>
         <volume>4657892</volume>
         <latencyTimestamp>201100501</latencyTimestamp>
         </MarketEvent>
    <?xml version="1.0" encoding="UTF-8"?>
         <MarketEvent>
         <eventTimeStamp>201100501</eventTimeStamp>
         <symbol>wet</symbol>
         <price>3005.02</price>
         <volume>4657892</volume>
         <latencyTimestamp>201100501</latencyTimestamp>
         </MarketEvent>
    I have also wrote one converter bean:
    package com.customer;
    import com.bea.wlevs.adapters.jms.api.InboundMessageConverter;
    import com.bea.wlevs.adapters.jms.api.MessageConverterException;
    import com.bea.wlevs.adapters.jms.api.OutboundMessageConverter;
    import com.bea.wlevs.example.algotrading.event.MarketEvent;
    import javax.jms.JMSException;
    import javax.jms.Message;
    import javax.jms.Session;
    import javax.jms.TextMessage;
    import java.util.ArrayList;
    import java.util.List;
    public class MessageConverter implements InboundMessageConverter, OutboundMessageConverter {
    public List<MarketEvent> convert(Message message) throws MessageConverterException, JMSException {
    MarketEvent event = new MarketEvent();
    TextMessage textMessage = (TextMessage) message;
    event.setString_1(textMessage.getText());
    List<MarketEvent> events = new ArrayList<MarketEvent>(1);
    events.add(event);
    return events;
    public List<Message> convert(Session session, Object inputEvent) throws MessageConverterException, JMSException {
         MarketEvent event = (MarketEvent) inputEvent;
    TextMessage message = session.createTextMessage("Text message: " + event.getString_1());
    List<Message> messages = new ArrayList<Message>();
    messages.add(message);
    return messages;
    this is converting xml messages to event.
    Edited by: 856272 on Jul 1, 2011 6:09 AM

  • Is there a way to turn the pattern matching example in Labview to instead of loading a rectangle around what you want the template to be you can use an image display , I've be trying and can get no where with it

    What I want to do is , have two images on image displays and the pass them through the same setup as the pattern matching example to get the number of matches , I have attached what I have done and also given the pattern matching example program as well.
    Hope to get answers back soon,
                                     Thanks Alan
    Attachments:
    screenshot.docx ‏48 KB
    Pattern Matching Example.vi ‏100 KB

    Hi there!
    The example used can be adapted for comparing two images, however the algorithm and coding for finding the differences is more specific to your actual problem. In terms of the loading and displaying of the images, this can be done in the same way.
    Once you have some sort of algorithm, then you can automate the learning and matching by simply wiring them in order. (in the example, these are put in case structures as they are waiting on response from the front panel)
    I hope that this helps,
    Liam A.
    National Instruments
    Applications Engineer

  • Regular Expressions (Pattern/Matcher) --- Help

    Hi,
    I have an regex i.e. Pattern.compile("([0-9])D([0-9])'?(?:([0-9]+)\")?([NSEW])").{code}
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507
    According to the bug report, they have said that are many different regex that can trigger the stack overflow....even though the length of my input is not as long as the one posted on the bug report.
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I missed the '+' in my original regex Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])"){code}.
    I have also tried {code} Pattern.compile("(\\d+)D(\\d+)'?(?:(\\d+)\")?([NSEW])");And, the other 2 expressions as suggested by you.
    The problem happens when Durham Lat=”35D52’N” Lon=”78D47’W value is selected from a Jtree(the values are parsed from a xml file to the tree - the xml file has a bout 800 longitude/latitude elements for different cities in the US). It does not happen for other values and If I increment the degree or min by, then the expression works. I am not sure how else i could re-write this exp.
    Below is the snippet of the xml file:
    <State name="NORTH CAROLINA">
                <City name="Asheville AP"     Lat="35D26'N"     Lon="82D32'W"/>
                <City name="Charlotte AP"     Lat="35D13'N"     Lon="80D56'W"/>
                <City name="Durham"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Elizabeth City AP"     Lat="36D16'N"     Lon="76D11'W"/>
                <City name="Fayetteville, Pope AFB" Lat="35D10'N"     Lon="79D01'W"/>
                <City name="Goldsboro,Seymour-Johnson"     Lat="35D20'N"     Lon="77D58'W"/>
                <City name="Greensboro AP (S)"     Lat="36D05'N"     Lon="79D57'W"/>
                <City name="Greenville"     Lat="35D37'N"     Lon="77D25'W"/>
                <City name="Henderson"     Lat="36D22'N"     Lon="78D25'W"/>
                <City name="Hickory"     Lat="35D45'N"     Lon="81D23'W"/>
                <City name="Jacksonville"     Lat="34D50'N"     Lon="77D37'W"/>
                <City name="Lumberton"     Lat="34D37'N"     Lon="79D04'W"/>
                <City name="New Bern AP"     Lat="35D05'N"     Lon="77D03'W"/>
                <City name="Raleigh/Durham AP (S)"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Rocky Mount"     Lat="35D58'N"     Lon="77D48'W"/>
                <City name="Wilmington AP"     Lat="34D16'N"     Lon="77D55'W"/>
                <City name="Winston-Salem AP"     Lat="36D08'N"     Lon="80D13'W"/>
            </State>
    public final class GeoLine {
        /* Enum for the possible directions of longitude and latitude*/
        public enum Direction {
            N, S, E, W;
            public boolean isLongitude() {
                return (this == E || this == W);
            public boolean isLatitude() {
                return (this == N || this == S);
            public Direction getCanonicalDirection() {
                if (this == S) {
                    return Direction.N;
                } else if (this == W) {
                    return Direction.E;
                } else {
                    return this;
        private final int degree;
        private final int minute;
        private final int second;
        private final Direction dir;
        /* Recognizes longitude and latitude values that has degrees, minutes and seconds i.e. "45D15'34"N
        * or "45D1534"N. The single-quotes for the minutes is optional. And, for the moment we do not support seconds
        * validation although ilog library returns the longitude/latitude with second when NEs and Sub-networks are
        * dragged and dropped on the map.*/
    private static final Pattern PATTERN = Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])");
        public GeoLine(int degree, int minute, Direction dir) {
            this(degree, minute, 0, dir);
        public GeoLine(int degree, int minute, int second, Direction dir) {
            Log.logInfo(getClass().getSimpleName(), "PAU degree: " + degree + " minute: " + minute + " second: " + second + " direction: " +  dir);
            verifyLongitudeLatitude(degree, dir);
            verifyMinute(degree, minute, dir);   
            this.degree = degree;
            this.minute = minute;
            this.second = second;
            if (this.degree == 0 && this.minute == 0 && this.second == 0) {
                this.dir = dir.getCanonicalDirection();
            } else {
                this.dir = dir;
        public Direction getDirection() {
            return dir;
        public int getMinute() {
            return minute;
        public int getDegree() {
            return degree;
        public int getSecond() {
            return second;
        public static GeoLine parseLine(String location) {
            * Matcher class will throw java.lang.NullPointerException if a null location
            *  is passed, null location validation is not needed.
            Matcher m = PATTERN.matcher(location);
            if(m.matches()) {
                int deg;
                int min;
                int second;
                Direction direction;
                deg = Integer.parseInt(m.group(1));
                min = Integer.parseInt(m.group(2));
                if (m.group(3) == null) {
                    second = 0;
                } else {
                    second = Integer.parseInt(m.group(3));
                direction = Direction.valueOf(m.group(4));
                return new GeoLine(deg, min, second, direction);
            } else {
                throw new IllegalArgumentException("Invalid location value. Expected format XXDXX'XX\"[NSEW] " + location);
        private void verifyMinute(int deg, int min, Direction direction) {
            /* This validation is to make sure that minute does not exceed 0 if maximum value for latitude == 90
            * or longitude == 180 is specified */
            int maxDeg = direction.isLatitude() ? 90 : 180;
            if(min < 0 || min > 59) {
               throw new NumberFormatException("Minutes is out of range. Value should be less than 60: " + min);
            if (deg == maxDeg && min > 0) {
                throw new NumberFormatException("Degree value " + deg + "D" + direction + " cannot have minute exceeding 0: " + min);
        private void verifyLongitudeLatitude(int valDeg, Direction valDir) {
               int max = valDir.isLatitude() ? 90 : 180;
               if(valDeg < 0 || valDeg > max) {
                    throw new NumberFormatException("Degree " + valDeg + valDir + " is invalid");
        public final boolean isLongitude() {
            return dir.isLongitude();
        public final boolean isLatitude() {
            return dir.isLatitude();
        @Override
        public final String toString(){
            if(minute < 10){
                return degree + "D0" + minute + dir;
            } else {
                return degree + "D" + minute + dir;
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof GeoLine) {
                GeoLine other = (GeoLine) obj;          
                    return (this.degree == other.degree && this.minute == other.minute && this.second == other.second && this.dir == other.dir);
            return false;
        @Override
        public int hashCode() {
            int result = 17;
            result = result * 37 + degree;
            result = result * 37 + minute;
            result = result * 37 + second;
            result = result * 37 + dir.hashCode();
            return result;
    }Thank you again.

  • Pattern Matching and Vision Builder 6.0

    Hi,
    When I select a ROI from an image to generate a pattern matching, Builder
    saves it as a PNG file.
    If I open this pattern in other application (Paint Shop Pro 7) to modified
    it and save as a PNG file, after I can't open this file as a pattern into
    Builder, because it is considered as a not valid PNG file.
    I have tested this case in LabView 6.i and this problem doesn't appear.
    Any solution? Thanks.

    When the template is first saved in Vision Builder, pattern matching information is stored in the header of the PNG file. This information lets LabVIEW and Vision Builder know how the template was learned. Paint Shop Pro does not keep this information in the file whenever it is saved so Vision Builder will not recognize it as a valid pattern matching template.
    Jack Arnold
    Application Engineer
    National Instruments

  • 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! :-)

  • Pattern matching in String

    Hi,
    I want to do pattern matching using String. Here is my requirement.
    String file_name = (String)hash.get("DOCNAME"));
    file_name = file_name.replace("'","285745@");
    So, whereever I have '(apostrophe) I will replace it with pattern "285745@" and then at another jsp where I get this request parameter I do reverse as follows:
    String docname = (String)request.getParameter("doc_name").replace("285745@","'");
    Now I know replace function is not going to do this. It is just a indicative, for you to know what I want to achieve. which other java function / method i can implement to get the desired result.
    thanks,
    pp

    String file_name = (String)hash.get("DOCNAME"));
    file_name = file_name.replace("'","285745@");The problem here is that String.replace() operates only on char arguments, you cannot replace entire substrings with it.
    The String.replaceAll() method, on the other hand, operates on regular expressions. In many common cases (those in which the substring you want to find contains no characters with special meaning to the regular expression processor) you can use it exactly as you would String.replace() except that it operates on substrings.
    But regular expressions are much more powerful than that. The javadoc for the "Pattern" class has some information on how to use them. There is also a tutorial at http://java.sun.com/docs/books/tutorial/extra/regex/intro.html which you might find helpful.
    In the 1.4 edition of Java there is no longer any need to screw around with while loops and StringBuffers. Nearly any text processing operation can be done with regular expressions.

  • USB SNAP + colour pattern matching ( IMAQ)

    I am new to LAbView and currently  I am working on colour pattern matching with USB snap. My problem is this program keep prompt me on the IMAQ Learn Colour Pattern. I need someone to help me solve that problem.
    Another question is 'Are colour pattern matching require us to save and load file before learn a template?'
    I am using LabView 7.1 and I would appreciate anyone who help me. Thanks
    Message Edited by Chee Hou on 09-16-2009 03:46 AM
    Attachments:
    Untitled.vi ‏189 KB

    Hello Chee Hou,
    Have you tried to run the example to do color pattern matching?
    From the example, you do need to have a template picture ready when you are using the colour pattern matching.
    You need to Learn Colour Pattern and then load the pattern to do color pattern matching.
    Hope this helps.
    James
    - Meadow -
    LabVIEW 7.0 - 2011, Vision, RT, FPGA
    TestStand 3.0 - 4.5

Maybe you are looking for