Need help on Regular expression and query
Hi Guru's, Hope you all are doing great!.
I have a scenario's where i need do insert the data into table.
I have three scenarios :
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
Alex Romano
Kodali,Raj,S
pppppNow what i want is .
1. Alex Romano
if there is space between the string then i want to insert into first name and last name columns
2. Kodali,Raj,S
if its a comma between the string then i want to insert into last name , first name and middle name
3. if there is only one string then same insert into first name and last name.
I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
Can you please help me out.
WITH t AS (
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
from
SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
, max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
, max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME
FROM t
CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
GROUP BY str
) ;Currently i am putting a b and c if its null.
Thanks in advance!
user590978 wrote:
Hi Guru's, Hope you all are doing great!.
I have a scenario's where i need do insert the data into table.
I have three scenarios :
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
Alex Romano
Kodali,Raj,S
pppppNow what i want is .
1. Alex Romano
if there is space between the string then i want to insert into first name and last name columns
2. Kodali,Raj,S
if its a comma between the string then i want to insert into last name , first name and middle name
3. if there is only one string then same insert into first name and last name.
I wrote the query earlier to handle only comma and now i am trying but not able to use this all scenarios
Can you please help me out.
WITH t AS (
select 'Kodali,Raj,S' str from dual
union
select 'Alex Romano' from dual
union
select 'ppppp' from dual
select DECODE(trim(a),NULL,'a',trim(a)),DECODE(trim(b),NULL,'b',trim(b)),decode(trim(c),NULL,'c' ,trim(c))
from
SELECT max(decode(level,1,regexp_substr(str,'[^,]+',1,level))) a --INTO lFNAME
, max(decode(level,2,regexp_substr(str,'[^,]+',1,level))) b --INTO lLNAME
, max(decode(level,3,regexp_substr(str,'[^,]+',1,level))) c --INTO lMNAME
FROM t
CONNECT BY regexp_substr(str,'[^,]+',1,level) IS NOT NULL
GROUP BY str
) ;Currently i am putting a b and c if its null.
Thanks in advance!It's never a popular suggestion, but why not fix the design to begin with?
It's the year 2013, can a client not pass you a "complex" data structure consisting of first, middle and last name?
Why rely on an unreliable construct when there are so many more usable way to achieve this?
Cheers,
Similar Messages
-
Help with Regular Expressions and regexp_replace
Oh great Oracle Guru can I can gets some help
I need to clean up the phone numbers that have been entered in Oracle eBusiness per_phones table. Some of the phone numbers have dashes, some have spaces and some have char. I would just like to take all the digits out and then re-format the number.
Ex.
914-123-1234 .. output (914) 123-1234
9141231234 ..again (914) 123-1234
914 123 1234 .. (914) 123-1234
myphone ... just null
(914)-123-1234.. (914) 123-1234
I really tried to understand the regular expressions statments, but for some reason I just can't understand it.Hi,
Welcome to the forum!
I would create a user-defined function for this. I expect there will be a lot of exceptions to the regular rules (for example, strings that do not contain exactly 10 digits, such as '1-800-987-6543') that can be handled, but would require lots of nested fucntions and othwer complicted code if you had to do it in a single statement.
If you really want to do it with a regular expression:
SELECT phone_txt
, REGEXP_REPLACE ( phone_txt
, '^\D*' || -- 0 or more non-digits at the beginning of the string
'(\d\d\d)' || -- \1 = 3 consecutive digits
'\D*' || -- 0 or more non-digits
'(\d\d\d)' || -- \2 = 3 consecutive digits
'\D*' || -- 0 or more non-digits
'(\d\d\d)' || -- \3 = 4 consecutive digits
'\D*$' -- 0 or more non-digits at the end of the string
, '(\1) \2-\3'
) AS new_phone_txt
FROM table_x
; -
Need help with regular expression
I'm trying to use the java.util.regex package to extract URLs from html files.
The URLs that I am interested in extracting from the HTML look like the following:
<font color="#008000">http://forum.java.sun.com -
So, the URL is always preceeded by:
<font color="#008000">
and then followed by a space character and then a hyphen character. I want to be able to put all these URLs in a Vector object. This doesn't seem like it should be too difficult but for some reason I can't get anywhere with it. Any help would be greatly appreciated. Thanks!hi gupta am not sure of the java syntax but i can tell u about the regular expression...try this....
<font color="#008000">(http:\/\/[a-zA-Z0-9.]+) [-]
i dont know the java methods to call...just the reg exp...
Sanjay Acharya -
Need help with Airport Express and so on.
Ok so my main problem before getting into what I need help with here is that our MacBooks and now my iPhone 6 plus isn't staying online. Keep getting booted off and then I either have to select the network again or it will eventually go back on. If anyone has a solution or so please feel free to answer that as well. I'm running on Roadrunner with a Netgear 600 wireless router and a motorola modem. Both of which I'll leave the link to below for a better look.
My Main Question: So I'm looking at a new wireless router mainly and possibly a new modem. I know Apple products are trustworthy but how good is the Airport Express and other Airport products. Also what is the Maximum speed and Maximum data speed for the cheapest express station and if anyone knows the speeds of the other devices it would be greatly appreciated.DSL Router to Netgear 5-port Switch and I used the switch to connect to Airport Extreme, TV, Blue-Ray DVD player and DirecTV Receiver.
The AirPort Extreme base station (AEBS) is a router so it will do what you need.
You need to reconfigure your setup. Connect the WAN port of the AEBS to the DSL router. Then connect the Netgear switch to one of the LAN ports on the AEBS. The AEBS will properly share the connection. -
Need help with Regular Expressions
This is my XML code
*<name>J. E. O'Rrrrrr, S. Mmmmmmmmmm, B. G. Mmmmmmmm, A. B. C. Xxxxxx Yyyyy, A. B. C. Zzzz and C. R. McCcccc</name>*
This is my source code
Regex = Pattern.compile("<name>.*?</name>");
RegexMatcher = Regex.matcher(fetchWholeFile);
while(RegexMatcher.find())
chkEnty = RegexMatcher.group();
Pattern RegexTry1 = Pattern.compile("([A-Z]{1}\\.[A-Z]{1}\\.[A-Z]{1}\\.){color:#ff6600}|{color}([A-Z]{1}\\.\\s[A-Z]{1}\\.\\s[A-Z]{1}\\.){color:#ff6600}|{color}([A-Z]{1}\\.[A-Z]{1}\\.){color:#ff6600}|{color}([A-Z]{1}\\.\\s[A-Z]{1}\\.){color:#ff6600}|{color}([A-Z]{1}\\.)");
//In the above line I am trying to catch all the initials (3 initals, 2 initials & 1 initial)
Matcher RegexMatcherTry1 = RegexTry1.matcher(chkEnty);
while(RegexMatcherTry1.find())
String chkEntyTry1 = RegexMatcherTry1.group();
Tagged11="<fname>"+chkEntyTry1+"</fname>";
fetchWholeFile=fetchWholeFile.replace(chkEntyTry1,Tagged11);
After executing the above code, my out is
*<name><fname>J.</fname>* E. O'Rrrrrr, *<fname>S.</fname>* Mmmmmmmmmm, *<fname><fname><fname><fname>B.</fname></fname></fname></fname> <fname>G.</fname>* Mmmmmmmm, *<fname>A.</fname>* *<fname><fname><fname><fname>B.</fname></fname></fname></fname>* *<fname>C.</fname>* Xxxxxx Yyyyy, *<fname>A.</fname>* *<fname><fname><fname><fname>B.</fname></fname></fname></fname>* *<fname>C.</fname>* Zzzz and *<fname>C.</fname>* *<fname><fname>R.</fname></fname>* McCcccc*</name>*
But I need my out as below
*<name><fname>J. E. </fname><sname>O'Rrrrrr</sname>,* *<fname>S. </fname><sname>Mmmmmmmmmm</sname>*, *<fname>B. G. </fname><sname>Mmmmmmmm</sname>*, *<fname>A. B. C. </fname><sname>Xxxxxx Yyyyy</sname>*, *<fname>A. B. C. </fname><sname>Zzzz </sname>and <fname>C. R. </fname><sname>McCcccc</sname></name>*
Could some also tell me how do I apply *<sname>*prometheuzz my source code as suggested by you is
public void lineread(String FileName)
try
File asciiFile1 = new File(FileName);
File tmp = new File(asciiFile1.getParent(),"Temp.xml");
BufferedReader br = new BufferedReader(new FileReader(asciiFile1));
BufferedWriter bw = new BufferedWriter(new FileWriter(tmp));
String line = "";
while((line = br.readLine()) != null)
fetchWholeFile+=line;
Pattern Regex = Pattern.compile("<ref.list>.*?</ref.list>");
Matcher RegexMatcher = Regex.matcher(fetchWholeFile);
while(RegexMatcher.find())
chkEnty = RegexMatcher.group();
Regex = Pattern.compile("<name>.*?</name>");
RegexMatcher = Regex.matcher(chkEnty);
while(RegexMatcher.find())
chkEnty = RegexMatcher.group();
Matcher m1 = Pattern.compile("([A-Z]\\.\\s?)+").matcher(chkEnty);
while(m1.find())
String Fname1=(m1.group());
String Fname2=("<fname>"+m1.group()+"</fname>");
FnameVector1.addElement(Fname1);
FnameVector2.addElement(Fname2);
Matcher m2 = Pattern.compile("([A-Z]['a-z]+\\s?)+").matcher(chkEnty);
while(m2.find())
String Sname1=(m2.group());
String Sname2=("<sname>"+m2.group()+"</sname>");
SnameVector1.addElement(Sname1);
SnameVector2.addElement(Sname2);
for(int v=0;v<FnameVector1.size();v++)
System.out.println(FnameVector1.elementAt(v));//It's printing fine here
for(int v=0;v<FnameVector2.size();v++)
System.out.println(FnameVector2.elementAt(v));//It's printing fine here
fetchWholeFile=fetchWholeFile.replace(FnameVector1.elementAt(v).toString(), FnameVector2.elementAt(v).toString());//But if I update to input XML file, it's wrong as shown below
for(int v=0;v<SnameVector1.size();v++)
System.out.println(SnameVector1.elementAt(v));//It's printing fine here
for(int v=0;v<SnameVector2.size();v++)
System.out.println(SnameVector2.elementAt(v));//It's printing fine here
fetchWholeFile=fetchWholeFile.replace(SnameVector1.elementAt(v).toString(), SnameVector2.elementAt(v).toString());//But if I update to input XML file, it's wrong as shown below
bw.write(fetchWholeFile);
bw.flush();
bw.close();
br.close();
File org = new File(FileName);
System.gc();
System.out.println(asciiFile1.delete());
tmp.renameTo(org);
catch(IOException ioe)
System.out.println(ioe);
This is my XML file
<?xml version="1.0" encoding="UTF-8"?>
<ref-list>
<name>A. B. Cccccc and X. Y. Zzzzzz</name>
<name>K. Name</name>
The output after executing the above source code is
<?xml version="1.0" encoding="UTF-8"?>
<ref-list>
<name><fname>A. </fname>B. <sname>Cccccc</sname>and <fname>X. <fname>Y. </fname></fname><sname>Zzzzzz</sname></name>
<name><fname><fname><fname><fname><fname><fname>K. </fname></fname></fname></fname></fname></fname><sname>Name</sname></name>
But I need my output as
<?xml version="1.0" encoding="UTF-8"?>
<ref-list>
<name><fname>A. B. </fname><sname>Cccccc</sname>and <fname>X. Y. </fname><sname>Zzzzzz</sname></name>
<name><fname>K. </fname><sname>Name</sname></name>
Please tell me where have I gone wrong. -
Regular Expression and PL/SQL help
I am using Oracle 9i, does 9i support regular expression? What functions are there?
My problem is the birth_date column in my database comes from teleform ( a scan program that reads what people wrote on paper), so the format is all jacked up.... 50% of them are 01/01/1981, 10% are 5/14/1995, 10% are 12/5/1993, 10% are 1/1/1983, 10% are 24-JUL-98. I have never really used regular expression and pl/sql, can anybody help me convert all of them to 01/01/1998?
Does Oralce 9i support regular expression? What can I do if oralce 9i does not support regular expression? Thank you very much in advance.9i doesn't support regular expressions (at least not in the 10g regular expressions sense. There is an OWA_PATTERN_MATCH package that has some facilities for regular expressions). But it doesn't look like this is a regular expressions problem.
Instead, this is probably a case where you need to
- enumerate the format masks you want to try
- determine the order you want to try them
- write a small function that tries each format mask in succession until one matches.
Of course, there is no guarantee that you'll ever be able to convert the data to the date that the user intended because some values will be ambiguous. For example, 01/02/03 could mean Feb 1, 2003 or Jan 2, 2003 or Feb 3, 2001 depending on the person who entered the data.
Assuming you can define the order, your function would just try each format mask in turn until one generated a valid date, i.e.
BEGIN
BEGIN
l_date := TO_DATE( p_string_value, format_mask_1 );
RETURN l_date;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
l_date := TO_DATE( p_string_value, format_mask_2 );
RETURN l_date;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
l_date := TO_DATE( p_string_value, format_mask_3 );
RETURN l_date;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
l_date := TO_DATE( p_string_value, format_mask_N );
RETURN l_date;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RETURN NULL;
END;Justin -
Can somebody help me in getting some good material for Regular Expressions and IP Community list
can somebody help me in getting some good material for Regular Expressions and IP Community list
I'm not sure what you mean by "IP Community list", but here are 3 reference sites for Regular Expressions:
Regular Expression Tutorial - Learn How to Use Regular Expressions
http://www.regular-expressions.info/tutorial.html
Regular Expressions Cheat Sheet by DaveChild
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/
Regular Expressions Quick Reference
http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm -
Help with Regular Expression for field validation
I'm fairly new to using regular expressions and using Acrobat. This is probably a simple question, but I've been unable to figure it out.
I have a text field on a PDF that I would like to be 9 characters in length. The first 2 characters can only be alphanumeric, the last 7 characters can only be numeric.
At first I was using the following, which allows all the characters to be alphanumeric:
var re = /^[A-Za-z0-9 :\\_]$/;
if (event.change.length >0) {
if (event.willCommit == false) {
if (!re.test(event.change)) {
event.rc = false
That works fine, but it's not quite what I needed. With some assistance I changed it (see below) to fit what I was looking for. However, this didn't work; it prevents anything from being entered in the field:
var re = /^[A-Za-z0-9]{2}\d{7}$/;
if (event.change.length >0) {
if (event.willCommit == false) {
if (!re.test(event.change)) {
event.rc = false
Any help would be greatly appreciated.
Thanks...Here's a function you can call form the field's custom Format script. It should be placed in a document-level JavaScript:
function custom_ks1() {
// Define non-commited regular expression
var re = /^[A-Za-z0-9]{0,2}([0-9]{0,7})?$/;
// Get all of the characters the user has entered
var value = AFMergeChange(event);
// Allow field to be cleared
if(!value) return;
if (event.willCommit) {
// Define commited regular expression
var re = /^[A-Za-z0-9]{2}[0-9]{7}$/;
if (!re.test(value)) { // If final value doesn't match, alert user
app.alert("Your error message goes here.");
// event.rc = false
} else { // not commited
// Only allow characters that match the regular expression
event.rc = re.test(value);
Call it like this:
// Custom Keystroke script
custom1_ks(); -
Help with regular expression to find a pattern in clob
can someone help me writing a regular expression to query a clob that containts xml type data?
query to find multiple occurrences of a variable string (i.e <EMPID-XX> - XX can be any number). If <EMPID-01> appears twice in the clob i want the result as EMPID-01,2 and if EMPID-02 appears 4 times i want the result as EMPID-02,4.with
ofx_clob as
(select q'~
<EMPID>1
< UNQID>123456
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>2
< UNQID>123457
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>1
< UNQID>123458
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
~' ofx from dual
select '<EMPID>' || to_char(ids) || '(' || to_char(count(*)) || ')' multi_empid
from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
from ofx_clob
connect by level <= regexp_count(ofx,'<EMPID>')
group by ids having count(*) > 1
MULTI_EMPID
<EMPID>1(2)
with
ofx_clob as
(select q'~
<EMPID>1
< UNQID>123456
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>2
< UNQID>123457
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>1
< UNQID>123456
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>2
< UNQID>123456
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
<EMPID>1
< UNQID>123458
< TIMESTAMP>...
< ADDRINFO>
< TITLE>^@~*
< FIRST>ABCD
< MI>
< LAST>EFGH
< ADDR1>ADDR1
< ADDR2>^@~*
< CITY>CITY
~' ofx from dual
select '<EMPID>' || listagg(to_char(ids) || '(' || to_char(count(*)) || ')',',') within group (order by ids) multi_empid
from (select replace(regexp_substr(ofx,'<EMPID>\d*',1,level),'<EMPID>') ids
from ofx_clob
connect by level <= regexp_count(ofx,'<EMPID>')
group by ids having count(*) > 1
MULTI_EMPID
<EMPID>1(3),2(2)
Regards
Etbin
Message was edited by: Etbin
used listagg to report more than one multiple <EMPID> -
Regular expressions and backreference
Hello!
I am trying to use backreferences in REGEXP in the PERL-style, where I want to match my regular expression and later refer to the grouped values. I can read that those are referecenced with \1 .. \9, but I simply cant get it to work. Here is an example in PL/SQL:
SELECT REGEXP_SUBSTR(l_users.adresse,'([A-Z]+)\s+(\d+)')
INTO l_dummy_varchar2
FROM dual;
OR I could do things like:
l_dummy_varchar2 := REGEXP_SUBSTR(l_users.adresse,'([A-Z]+)\s+(\d+)');
It seems to work, but I cant figure out how to get the backreferenced value.
I would love to do things like:
dbms_output.put_line('my value ='||\1)
but this doesnt work.
Help is very much appreciated.
Best regards
DannieLikewise you can extract things using the
REGEXP_SUBSTR, but you don't need back
referencing...backreferencing is better than additional function (ltrim) use, and BTW be careful with this "ltrims":
SQL> set serveroutput on
SQL>
SQL> DECLARE
2 v_txt VARCHAR2(100);
3 BEGIN
4 v_txt := ltrim(regexp_substr('HERE IS AN ASCII CHARACTER', 'IS AN [[:alnum:]]*'),'IS AN ');
5 DBMS_OUTPUT.PUT_LINE('Word after IS AN: '||v_txt);
6 END;
7 /
Word after IS AN: CII
PL/SQL procedure successfully completed
SQL>
SQL> DECLARE
2 v_txt VARCHAR2(100);
3 BEGIN
4 v_txt := regexp_replace('HERE IS AN ASCII CHARACTER', 'IS AN ([[:alnum:]]*)|.','\1');
5 DBMS_OUTPUT.PUT_LINE('Word after IS AN: '||v_txt);
6 END;
7 /
Word after IS AN: ASCII
PL/SQL procedure successfully completed
SQL> -----------
VB
http://volder-notes.blogspot.com/ -
Juniper MX Regular expressions and user permissions ACS 5.4
Hi everyone!
Im having some trouble with regular expressions and permissions on our Juniper MX routers through ACS 5.4, and i would like some insight/help/poitners!!
We have a team of engineers that should only have read only permissions (important: show configuration) and also be able to just change the description on interfaces.
Thus far with the following regular expressions set for the shell profile they are going through i have managed the above, however the problem is when an engineer inputs "Show configuration", only the interfaces descriptions configuration is shown! The rest of the configuration will not be printed.
deny-commands1=.*.
allow-commands1=configure
deny-configuration1=.*.
allow-commands2=interfaces .*. description .*$
allow-configuration1=interfaces .*. description .*$
allow-commands2=show configuration.*
allow-commands3=show configuration
(some of these regex i know that are not needed, i was just playing around to check everything before posting)
Any pointers as to why or how to resolve this?
example output with the above:
show configuration
## Last commit: 2014-01-09 09:34:44 EET by someone
interfaces {
xe-0/0/0 {
xe-0/0/1 {
description xxxx;
xe-0/1/0 {
description xxxx;
xe-0/1/1 {
description xxxx;
xe-0/2/0 {
disable;
xe-0/2/1 {
description xxxx;
xe-0/3/0 {
description xxxx;
xe-0/3/1 {
description xxxx;
ae0 {
description "xxxx";
ae1 {
description xxxx;
demux0 {
lo0 {
{master}
Thanks in advance!
SpyrosYou are absolutely right!! I was doing research online after posting the above. The correct RADIUS attribute to use is actually CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools. Then create the pool in ASA, and call that pool's name in ACS under that RADIUS attribute. Someone explained this perfectly in this community before. Much appreciate your answer!
Here's from another post last year:
ACS 5 does not have the feature of IP pools. Logically its always good to setup pools locally on vpn server and if you want user to pick ip from specific local pool you can configure acs to push that attribute.
On ACS Go to > Policy Elements -> Network Access -> Authorization Profiles -> Create ->
Name of the Policy ->Dictionary Type: Radius-Cisco VPN 3000/ASA/PIX7.x
Attribute Type : CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools
Attribute Type: String
Attribute Value : Static MYPOOL (Name of the Pool which is defined on the ASA)
Access Policies ->Default Network Access -> Authorization -> Create -> Under result section call the Authorization p -
"Match Regular Expression" and "Match Pattern" vi's behave differently
Hi,
I have a simple string matching need and by experimenting found that the "Match Regular Expression" and "Match Pattern" vi's behave somewhat differently. I'd assume that the regular expression inputs on both would behave the same. A difference I've discovered is that the "|" character (the "vertical bar" character, commonly used as an "or" operator) is recognized as such in the Match Regular Expression vi, but not in the Match Pattern vi (where it is taken literally). Furthermore, I cannot find any documentation in Help (on-line or in LabVIEW) about the "|" character usage in regular expressions. Is this documented anywhere?
For example, suppose I want to match any of the following 4 words: "The" or "quick" or "brown" or "fox". The regular expression "The|quick|brown|fox" (without the quotes) works for the Match Regular Expression vi but not the Match Pattern vi. Below is a picture of the block diagram and the front panel results:
The Help says that the Match Regular Expression vi performs somewhat slower than the Match Pattern vi, so I started with the latter. But since it doesn't work for me, I'll use the former. But does anyone have any idea of the speed difference? I'd assume it is negligible in such a simple example.
Thanks!
Solved!
Go to Solution.Yep-
You hit a point that's frustrated me a time or two as well (and incidentally, caused some hair-pulling that I can ill afford)
The hint is in the help file:
for Match regular expression "The Match Regular Expression function gives you more options for matching
strings but performs more slowly than the Match Pattern function....Use regular
expressions in this function to refine searches....
Characters to Find
Regular Expression
VOLTS
VOLTS
A plus sign or a minus sign
[+-]
A sequence of one or more digits
[0-9]+
Zero or more spaces
\s* or * (that is, a space followed by an asterisk)
One or more spaces, tabs, new lines, or carriage returns
[\t \r \n \s]+
One or more characters other than digits
[^0-9]+
The word Level only if it
appears at the beginning of the string
^Level
The word Volts only if it
appears at the end of the string
Volts$
The longest string within parentheses
The first string within parentheses but not containing any
parentheses within it
\([^()]*\)
A left bracket
A right bracket
cat, cag, cot, cog, dat, dag, dot, and dag
[cd][ao][tg]
cat or dog
cat|dog
dog, cat
dog, cat cat dog,cat
cat cat dog, and so on
((cat )*dog)
One or more of the letter a
followed by a space and the same number of the letter a, that is, a a, aa aa, aaa aaa, and so
on
(a+) \1
For Match Pattern "This function is similar to the Search and Replace
Pattern VI. The Match Pattern function gives you fewer options for matching
strings but performs more quickly than the Match Regular Expression
function. For example, the Match Pattern function does not support the
parenthesis or vertical bar (|) characters.
Characters to Find
Regular Expression
VOLTS
VOLTS
All uppercase and lowercase versions of volts, that is, VOLTS, Volts, volts, and so on
[Vv][Oo][Ll][Tt][Ss]
A space, a plus sign, or a minus sign
[+-]
A sequence of one or more digits
[0-9]+
Zero or more spaces
\s* or * (that is, a space followed by an asterisk)
One or more spaces, tabs, new lines, or carriage returns
[\t \r \n \s]+
One or more characters other than digits
[~0-9]+
The word Level only if it begins
at the offset position in the string
^Level
The word Volts only if it
appears at the end of the string
Volts$
The longest string within parentheses
The longest string within parentheses but not containing any
parentheses within it
([~()]*)
A left bracket
A right bracket
cat, dog, cot, dot, cog, and so on.
[cd][ao][tg]
Frustrating- but still managable.
Jeff -
Regular Expressions and Full-text Requests.
Hi,
i have just read that Berkeley DB XML doesnt support regexp in XQuery (what a pity),
do you know how to look-alike regular expressions in Query?
for example, i'd like to perform a full-text request, all tags that contains text like "Be.+ley" (it would return tags that contains text like "Berkeley" or "Beverley"), how can i do that?
Thx.Hi,
A performant way to do something like you want is with a query that mixes use of contains() (index optimized) and matches() (not index optimized). Something like this:
collection()//tag[contains(., "Be") and contains(., "ley") and matches(., "Be.+ley")]John -
I have working regular expressions and a working sql connection, but I don�t know how to stop the info from getting into the database when input doesent match the regular expression.
For instans, you put in an e-mail without an "@" and my program writes and error message. But the info still gets in to the database.
Any help would be much apreciated as I dont know where to start. If you have links or code examples that would be great to.
Thanx.Well, the obvious answer is "only write the data to the database if the input doesn't match the regular expression."
Presumably you're really asking how to do that - but it depends upon how your application is structured in the first place, and you haven't told us anything at all about that. -
im learning about regular expressions and im i want to write a regular expression to split the string like this:
comp_complex=9
comp_medium=5
comp_simple=2
and store it in an array...but even after trying various combinations im unable to split it...i dont know how to start..please help.....
[{comp_complex=9, comp_medium=5, comp_simple=2, comp_id=111}, {comp_complex=0, comp_medium=5, comp_simple=0, comp_id=112}, {comp_complex=15, comp_medium=10, comp_simple=5, comp_id=113}, {comp_complex=14, comp_medium=7, comp_simple=2, comp_id=114}, {comp_complex=17, comp_medium=12, comp_simple=5, comp_id=115}, {comp_complex=15, comp_medium=8, comp_simple=3, comp_id=116}]I think I can guess - String[] splitLine = line.replaceAll("[\\[\\]{}\\s]+","").split(",");
Maybe you are looking for
-
Code is only valid for users of store
Help.... Ive just gifted an app to my son as I often do and when he tries to redeem it it says "This code is only valid for customers of the Store". Ive looked this up and normally it will involve someone from one country trying to gift an app to som
-
WRV200 IPSEC VPN to a remote site with 2 different subnets
Hi, My old WRV54G had no problem with this! I'm trying to connect an IPSEC tunnel back to a router at my main office, there are two Subnets there 192.168.0.0/24 and 10.171.131.0/24. In my old router I would set up two tunnels to the same gateway with
-
Scenario of Import P.O from same material get money from vendor and custome
Hi Experts, My client is procuring certain material Quantity 10 by Import, As when he recieve the 10 Quantity material he founds 8 Quantity is to be Okay and the other 2 founds to be damaged, As it is import material he cannot return it to import ven
-
I tried to install the newest itunes, but just before it can finish installing, an error message appears saying "itunes cabinet file itunes.cab is corrupt and unusable." Please help. I've never had a problem with downloading and installing itunes ver
-
ERROR 1064 (42000): You have an error in your SQL syntax;
Folks, I stucked here while granting the permissions. could you please throw any ideas why this... mysql> GRANT SELECT, INSERT, DELETE ON database TO prod@localhost IDENTIFIED BY 'Welcome1' -> FLUSH PRIVILEGES; ERROR 1064 (42000): You have an error i