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.
Similar Messages
-
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. -
Pattern matching using Regular expression
Hi,
I am working on pattern matching using regular expression. I the table, I have 2 columns A and B
A has value 'A499BPAU4A32A386KBCZ4C13C41D20E'
B has value like '*CZ4*M11*7NQ+RDR+RSM-R9A-R9B'
the requirement is that I have to match the columns of B in A. If there is a value with * sign, this must be present in A like 'CZ4' should exit in string A.
The issue I am facing is that there are 2 values with * sign. The code works fine for first match (CZ4) but it does not look further as M11 does not exist in A.
I used the condition
AND instr(A,substr(REGEXP_SUBSTR(B, '*[^*]{3}'),2) ,1)=0
First of all, is this possible to match multiple patterns in one condition?
If yes, please suggest.
Thanksuser2544469 wrote:
Thanks a lot Frank. This query worked wonderful for the test data I have provided however I have some concerns:
- query doesnot include the column BOOK which is a mandatory check.Sorry, that was my mistake. It was a very easy mistake to make, since you posted sample data where it didn't matter. Instead of doing a cross-join between vn and got_must_have_cnt, do an inner join, using book. That means book will have to be in got_must_have_cnt, and all the sub-queries from which it descends. Look for comments that say "March 22".
If you want to treat '+' in test_cat.codes as '*', then the simplest thing is probably just to use REPLACE, so that when the table has '+', you use '*' instead.
WITH got_token_cnt AS
SELECT cat
, book -- Added March 22
, REPLACE (codes, '+', '*') AS codes -- If desired. Changed March 22
, LENGTH (codes) - LENGTH ( TRANSLATE ( codes
, 'x*+-'
, 'x'
) AS token_cnt
FROM test_cat
, cntr AS
SELECT LEVEL AS n
FROM ( SELECT MAX (token_cnt) AS max_token_cnt
FROM got_token_cnt
CONNECT BY LEVEL <= max_token_cnt
, got_tokens AS
SELECT t.cat
, t.book -- Added March 22
, REGEXP_SUBSTR ( t.codes
, '[*+-]'
, 1
, c.n
) AS token_type
, SUBSTR ( REGEXP_SUBSTR ( t.codes
, '[*+-][^*+-]*'
, 1
, c.n
, 2
) AS token
FROM got_token_cnt t
JOIN cntr c ON c.n <= t.token_cnt
, got_must_have_cnt AS
SELECT cat, book -- Changed March 22
, COUNT (CASE WHEN token_type = '*' THEN 1 END) AS must_have_cnt
FROM got_tokens
GROUP BY cat, book -- Changed March 22
SELECT mh.cat
, vn.vn_no
FROM got_must_have_cnt mh
JOIN vn ON mh.book = vn.book -- Changed March 22
LEFT OUTER JOIN got_tokens gt ON mh.cat = gt.cat
AND INSTR (vn.codes, gt.token) > 1
GROUP BY mh.cat
, mh.must_have_cnt
, vn.vn_no
HAVING COUNT (CASE WHEN gt.token_type = '*' THEN 1 END) = mh.must_have_cnt
AND COUNT (CASE WHEN gt.token_type = '-' THEN 1 END) = 0
ORDER BY mh.cat
- query is very slow with 60000 records in vn table. Cost is somewhere around 36000.See these threads:
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
Relational databases were designed to have (at most) one piece of information in each column. If you decide to have multiple items in the same column (as you have a variable number of tokens in the codes column), don't be surprised if that makes things slower and more complicated. Most of the query I posted, and perhaps most of the time needed, is jsut to normalize the data. If you stored the data in a narmalized form, perhaps something like got_tokens, then you wouldn't need the first 3 sub-queries that I posted.
Edited by: Frank Kulash on Mar 22, 2011 12:04 PM -
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,
PrashanthI 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 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,
preetipreetiGupta 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 KBHi 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,
SriSo 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 -
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
RickyHi,
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. -
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 advanceHi,
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=35D52N Lon=78D47W 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. -
Regular expression and pattern matching/replacing
I have a list of key words. It has around 1000 key word now but can grow to 5000 keywords.
My web application displays lot of texts which are stored in the database. My requirement is to scan each text for the occurance of any of the above keywords. If any keyword is present I have to replace that with some custom values, before showing it to the user.
I was thinking of using using regular expression for replacing the keyword in the text using matcher.replaceAll method as follows:
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
String output = matcher.replaceAll(replacementStr);
But My pattern string will have around 5000 keywords with the 'OR' Logical Operator like- keyword1| keyword2 I keyword3 | ..........
Will such a big pattern string adversly affect the performance? What can I do to speed up the performance? (Since my keyword list is not static i would prefer to do the replacement just before showing the text to the user)
Any suggestions are most welcome.I don't think a pure regex approach would be that slow, but it would be a maintenance nightmare. I think a combined regex/table-lookup approach would be best: use a regex to identify potential keywords, then look them up in the table to confirm. For instance, to find all Java keywords you could use the regex "\\b[a-z]{2,12}+\\b" to filter out anything that can't possibility be a keyword.
What are you going to replace the keywords with? Will it vary depending on which keyword is found? If so, you'll have to use a table--and you won't be able to use the replaceAll method, because it can't handle dynamically generated replacement values. You would have to use the lower-level appendReplacement and appendTail method instead. -
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 -
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.
Maybe you are looking for
-
How can i use a function in a create table?
I have done one funtion to do one check in a create table statement, but i don't know where to use it. How can I use it?
-
Regarding Enhanced Receiver Determination
Hi Experts, I go through the Blog /people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16 In this i am not getting the Source Msg Structure And Target Msg Structures Can any one Give me a LOOK at this
-
MSCS and Kernel patches: Can someone please refresh my memory?
Greetings, We run 4.7 Ent on a 2-node MSCS Cluster (SQL). I need to do a kernel upgrade, but I have forgotten the precise distribution of kernel files outside of the "run" directory for the cluster. I understand they are: Main Kernel Files shared_dri
-
Password restricted access for published Groupwise calendar
Hello, we want to publish our internal calendar. But I want to prevent, that everyone who knows the link-address has access to this calendar. So I tried to add the LDAP-authorisation to the /etc/opt/novell/groupwise/calhost/gwcal.conf as described in
-
Could not download the ordered file after five attaempts due to network problem
Hi, Could not download the ordered file after five attaempts due to network problem. Help required. Regards, Nilesh Shah.