Expand a Regular Expression
How do I expand a regular expression?
I mean if I have '12[3-5]' as my starting point. I want to see:
result
12[3-5]
123
124
125
Any help will be appreciated.
Thanks
I'd say you need a procedure that "interprets" a regular expression for generating all available string - good luck on this one. For short strings you could also try a "brute force" string generator that generates all possible combinations and filters them through a regular expression:
DECLARE
PROCEDURE check_regex(
p_regex IN VARCHAR2
, p_max_len IN NUMBER
IS
c_chars CONSTANT VARCHAR2(10) := '0123456789';
TYPE t_counter IS TABLE OF PLS_INTEGER INDEX BY PLS_INTEGER;
v_counter t_counter;
v_exit BOOLEAN := FALSE;
v_string VARCHAR2(255);
BEGIN
-- init loop
FOR i IN 1..p_max_len
LOOP
v_counter(i) := 1;
END LOOP;
-- show regular expression
DBMS_OUTPUT.put_line(p_regex);
WHILE NOT v_exit
LOOP
-- start generation
v_string := '';
FOR i IN 1..p_max_len
LOOP
v_string := v_string || SUBSTR(c_chars, v_counter(i), 1);
END LOOP;
-- filter the generated string through the regular expression
IF REGEXP_LIKE(v_string, p_regex) THEN
DBMS_OUTPUT.put_line(v_string);
END IF;
-- increment loop
FOR i IN REVERSE 1..p_max_len
LOOP
v_counter(i) := v_counter(i) + 1;
IF v_counter(i) > LENGTH(c_chars) THEN
IF i > 1 THEN
v_counter(i) := 1;
ELSE
v_exit := TRUE;
END IF;
ELSE
-- no further processing required
EXIT;
END IF;
END LOOP;
END LOOP;
END check_regex;
BEGIN
check_regex(p_regex => '12[3-5]', p_max_len => 3);
END; If you come up with a better solution, I'd be interested.
C.
Similar Messages
-
Regular Expressions in num-exp
Hello All,
I had a problem on my SRST gateway with num-exp insterting a repeating pattern into my 7-digit dialing when in fallback mode.
For a brief example, the 7digit internal dialing is 21621.. or 21622..
The num-exp statement of 'num-exp 2... 2162...' was not allowing me to 7-digit dial directly from one IP phone to another while in fallback mode.
When I dialed 2162154 the 2162 would hit the num-exp and be expended to 2162162.
I have a work around that uses a voice translation-rule, applied to the call-manager-fallback config that will translate a 7-digit dialed string to the 4 digit dialed string which then hits the 4-digit to 7-digit num-exp and it is working fine.
However, I was wondering if there is a way to use regular expressions in num-exp so that perhaps I can skip the intermediate step of using the translation-rule. Based off my existing translation-rules that are working properly, I figured something like this might work for num-exp:
'num-exp /^2\([12]..$\)/ /2162\1/'
But when I try to issue a num-exp with a regular expression I get the following message.
Incorrect format for Number macro pattern
regular expression must be of the form ^((\+)?([0-9#*A-F.]|(\\\*))+(\$)?)$
I have tried a number of different combinations with no success. I always get the same message. The regular expression that I tried first was:
'num-exp ^2... 2162...'
This is when I first saw the "Incorrect format..." message and figured that is must be possible. Is this just a generic warning similar to when you try to use complex regular expressions with the 'translation-rule' command vs. the 'voice translation-rule' command and in reality you cannot use regular expressions in the num-exp command?
Thank you,
LeoHi Chris,
Thank you for taking the time to answer my question. It looks like the answer is no, num-exp does not support regular expressions.
I don't insist on using num-exp for this I was just hoping to kill two birds with one stone and possibly skip the intermediate step of translating the 7-digits dial to 4-digits using a translation-rule just to expand from 4-digit to 7 again. This is only an issue while in SRST if a user tries to dial using 7-digits. We have a 7-digit internal dialing scheme and normally my num-exp is just to expand the 4 digits sent from the telco to our 7-digit internal dialing. The problem is that both our prefix and part of our DID range start with 21 so while in SRST if a user tried to dial a 7-digit DN, say 2162154, after they dialed the 4th digit (2162) that pattern would hit the num-exp and get expanded to 2162162. I was hoping to create a num-exp using a regular expression that would only expand a four digit string that begins with a 2 to seven digits and not any string that begins with a 2. This would 1) expand the four digits sent from the telco and 2) not match a seven digit string that begins with a 2 such as 2162154 which may be dialed by a user.
Again, this is only an issue while in SRST and I have a pretty good work around so I'm fine with not being able to use a regular expression as part of my num-exp config. I just thought it would be a cool application of a regular expression if it was possible.
Thanks again for answering my question.
Leo -
Regular Expression Search for Case Statement in VBA
Hi,
I'm having trouble trying to use regular expressions in a case statement. I have a CSV spreadsheet of a server's netstat output and am trying to plot everything into Visio. I have been able to do that, however I'm not trying to expand this capability and
resuse the same code for many different servers.
I have the mainServer variable set as a Variant and in my current example it is set as "INTPXY001" (internal proxy server 001). I have tried different regex statements for the potential to have INTPXY001 - INTPXY999, EXTPXY001 - EXTPXY999, and
SVCPXY001 - SVCPXY999 in place of the Case "INTPXY001", but nothing I have tried seems to work.
'========================================
Set mainServer As Variant
Set AppVisio = CreateObject("visio.application")
AppVisio.Visible = True
AppVisio.Documents.AddEx "", visMSDefault, 0
AppVisio.Documents.OpenEx "server_u.vss", visOpenRO + visOpenDocked
mainServer = ActiveSheet.Cells(1, 2) 'sets mainServer to INTPXY001
With AppVisio.ActiveWindow.Page
Select Case mainServer
Case "INTPXY001"
.Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.ItemU("Proxy server"), 2.25, 9.25
Case Else
.Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.Item(("Server"), 2.25, 9.25
End Select
End With
'========================================You cannot declare variables As Variant in VBScript. All variables in VBScript are implicitly variants.
If you are asking about VBA (Visual Basic for Applications), then you're not asking in the correct forum.
-- Bill Stewart [Bill_Stewart] -
Regular expression​.vi doesn't work correctly
I try to parse the output from "Flatten To XML" using "Find Regular Expression" but I get unexpected results.
Input: "<LvVariant><Name>myName</Name><Cluster>...</Cluster></LvVariant>"
Regular expression: "<(.+)><Name>(\w+)</Name>(.+)</\1>"
Expected result: match1 = "LvVariant", match2 = "myName", match3 = "<Cluster>...</Cluster>", total match = input, before match = empty, after match = empty.
LabVIEW's result: before match = input, all other output strings are empty.
I checked the expression with other programming languages like PHP and Delphi. There it works fine, but not in LabVIEW. I think, there is a bug at the "Find regular expression.vi".ralfc wrote:
I try to parse the output from "Flatten To XML" using "Find Regular Expression" but I get unexpected results.
Input: "<LvVariant><Name>myName</Name><Cluster>...</Cluster></LvVariant>"
Regular expression: "<(.+)><Name>(\w+)</Name>(.+)</\1>"
Expected result: match1 = "LvVariant", match2 = "myName", match3 = "<Cluster>...</Cluster>", total match = input, before match = empty, after match = empty.
LabVIEW's result: before match = input, all other output strings are empty.
I checked the expression with other programming languages like PHP and Delphi. There it works fine, but not in LabVIEW. I think, there is a bug at the "Find regular expression.vi".
You are not using the Match Regular Expression correctly, try this:
You need to expand the bottom of the vi to get the captured groups.
Ben64 -
I haven't used regular expressions before, and I'm having trouble finding a regular expression to extract a string subset between two markers.
The string;
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
ERRORS 6
Info I want line 1
Info I want line 2
Info I want line 3
Info I want line 4
Info I want line 5
Info I want line 6
END_ERRORS
From the string above (this is read from a text file) I'm trying to extract the string subset between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number 1 through 32, and the number of lines I want to extract will correspond with this number. I can supply this number from a calling VI if necessary.
My current solution, which works but is not very elegant;
(1) uses Match Regular Expression to the return the string after matching ERRORS 6
(2) uses Match Regular Expression returning all characters before match END_ERRORS of the string returned by (1)
Is there a way this can be accomplished using 1 Match Regular Expression? If so could anyone suggest how, together with an explanation of how the regular expression given works.
Many thanks
Alan
Solved!
Go to Solution.I used a character class to catch any word or whitespace characters. Putting this inside parentheses makes a submatch that you can get by expanding the Match Regular Expression node. The \d finds digits and the two *s repeat the previous term. So, \d* will find the '6', as well as '123456'.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
Regular expression on words with % wildcard
Hi,
I've got some processing working using regular expression where I need to process words e.g.
regexp_replace('word1 word2','(\w+)','myprefix{\1}') - results in - 'myprefixword1 myprefixword2'
However, if I'm presented with this; '%word0 word1% wo%d2 word3', then I need to treat % as special case and leave the word as is, so result here would be; - '%word0 word1% wo%d2 myprefixword3', is this achievable using regexp ?And for those who don't know, I guess we should explain why we're having to expand single spaces to double spaces...
(I'll use the "¬" character to represent spaces to make it clearer to see)
If we have a string such as
word1¬word2¬word3and we want to identify the words in the string (without using any special regexp word identifier) then we are going to use the spaces to identify the start and end of words. To make life easy, we manually put a space at the start and end of the string so we can say that each word in the string will have a space before and after it regardless of where it is in the string...
¬word1¬word2¬word3¬However, when we specify what we want to search for we are going to say we want a space, followed by a number of characters (not spaces), followed by a space...
¬[^¬]*¬So, ideally, you'd expect it to look through the string and say
¬word1¬word2¬word3¬
\_____/... found word1
¬word1¬word2¬word3¬
\_____/... found word2
¬word1¬word2¬word3¬
\_____/... found word3
Unfortunately, there is a problem. Once the first word has been found the pointer for searching the rest of the string is located on the next character after the match i.e.
¬word1¬word2¬word3¬
^So it won't be able to pick out word2 and will only get to word3. Let's see it in action...
SQL> ed
Wrote file afiedt.buf
1 with t as (select ' word1 word2 word3 ' as txt from dual)
2 --
3 select regexp_replace(txt, ' [^ ]* ', 'xxxxx') as txt
4* from t
SQL> /
TXT
xxxxxword2xxxxx
SQL>In order to deal with this, if we replace the single spaces with double spaces (not required at the start and end) our string looks like...
¬word1¬¬word2¬¬word3¬So as it searches it finds word1 as a match and then the pointer in the string is located...
¬word1¬¬word2¬¬word3¬
^... so the next match for the pattern of space-characters-space is word2 and then the pointer is located...
¬word1¬¬word2¬¬word3¬
^... ready to find word 3. Example...
SQL> ed
Wrote file afiedt.buf
1 with t as (select ' word1 word2 word3 ' as txt from dual)
2 --
3 select regexp_replace(txt, ' [^ ]* ', 'xxxxx') as txt
4* from t
SQL> /
TXT
xxxxxxxxxxxxxxx
SQL>Hopefully that's a little clearer. You just have to remember the "pointer" principle and the fact that once a match is found it is located on the character after the match.
;) -
Regular Expression - replaceAll() - how to replace words?
Hiya,
I have this regex to replace all instances of myWord:
String oldWord = "oldWord";
String newWord = "newWord";
String sentence = "some sentence that contains " + oldWord;
String newSentence = replaceWordsInSentence(sentence, oldWord, newWord);
private String replaceWordsInSentence(String sentence, String oldWord, String newWord) {
return sentence.replaceAll("\b" + oldWord + "\b", newWord);
}...it works in most instances, but when oldWord is at the end of the sentence it is not replaced. Presumably the problem is that "/b" is not a sufficient word boundary. Can someone help me out with the correct regular expression code?
Thanks,
JamesMel, you did appear to misunderstand as you thought points 2 and 3 were alternatives, but you now recognise that they are additional "shoulds".
Of course, I applied the extra backslash as soon as Joachim advised. Maybe you don't agree with my rationale, but I prefer the complete solution that will work in all instances... so was simply waiting for him to post a code example that included the latter 2 points as (although I understood the point of them perfectly) I was not sure how to implement them.
Have come up with the following, expanded, method...
private String replaceWordsInSentence(String sentence, String oldWord, String newWord) {
return sentence.replaceAll("\\b" + Pattern.quote(oldWord) + "\\b", Matcher.quoteReplacement(newWord));
}...works fine with the tests I have run. Joachim, can you confirm this is correct. -
Logical AND in Java Regular Expressions
I'm trying to implement logical AND using Java Regular Expressions.
I couldn't figure out how to do it after reading Java docs and textbooks. I can do something like "abc.*def", which means that I'm looking for strings which have "abc", then anything, then "def", but it is not "pure" logical AND - I will not find "def.*abc" this way.
Any ideas, how to do it ?
BakenFirst off, looks like you're really talking about an "OR", not an "AND" - you want it to match abc.*def OR def.*abc right? If you tried to match abc.*def AND def.*abc nothing would ever match that, as no string can begin with both "abc" and "def", just like no numeric value can be both 2 and 5.
Anyway, maybe regex isn't the right tool for this job. Can you not simply programmatically match it yourself using String methods? You want it to match if the string "starts with" abc and "ends with" def, or vice-versa. Just write some simple code. -
Hello..
I wanted to write a regular expression to match the foll string..
<!--endclickprintexclude--><!--startclickprintexclude--> <!--endclickprintexclude-->
<p> <b>NEW ORLEANS, Louisiana (CNN) </b>
-- Two years after Hurricane Katrina devastated coastal areas of Louisiana and Mississippi, residents say much of America has forgotten their plight.
</p> <!--startclickprintexclude-->
I tried doing..
Matcher matcher= Pattern.compile("<!--endclickprintexclude--> <p><b>([^<^>]+?)</p><!--startclickprintexclude-->", Pattern.CASE_INSENSITIVE).matcher(story);
Its not working...
is there any other soln?Theres probably a better way to do this but here's a way that works.
import java.util.regex.*;
public class RegexTester{
public static void main(String[] args){
String text =
"<!--endclickprintexclude--><!--startclickprintexclude--> <!--endclickprintexclude-->" +
"<p> <b>NEW ORLEANS, Louisiana (CNN) </b>" +
"-- Two years after Hurricane Katrina devastated coastal areas of Louisiana and Mississippi," +
"residents say much of America has forgotten their plight." +
"</p> <!--startclickprintexclude-->";
String regex = ">((?:\\s*[\\S&&[^<>]]+\\s*)*?)<";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(text);
while(m.find()){
System.out.println("Match: '" + m.group(1) + "'");
} -
Help in regular expression matching
I have three expressions like
1) [(y2009)(y2011)]
2) [(y2008M5)(y2011M3)] or [(y2009M5)(y2010M12)]
3) [(y2009M1d20)(y2011M12d31)]
i want regular expression pattern for the above three expressions
I am using :
REGEXP_LIKE(timedomainexpression, '???[:digit:]{4}*[:digit:]{1,2}???[:digit:]{4}*[:digit:]{1,2}??', 'i');
but its giving results for all above expressions while i want different expression for each.
i hav used * after [:digit:]{4}, when i am using ? or . then its giving no results. Please help in this situation ASAP.
ThanksI dont get your question Can you post your desired output? and also give some sample data.
Please consider the following when you post a question.
1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
You can use the following query and do a copy past of the output.
select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
that are asked the answer is already there.
3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
I have the following table called sales
with sales
as
select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
union all
select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
select *
from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
For example in the above sales table, I want to know the total quantity and number of invoice for each product.
The output should look like this
Prod_id sum_qty count_inv
1 145 2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
use the {noformat}{noformat} tags.
The usage of the tag is like this.
<place your code here>\
7. If you are posting a *Performance Related Question*. Please read
{thread:id=501834} and {thread:id=863295}.
Following those guide will be very helpful.
8. Please keep in mind that this is a public forum. Here No question is URGENT.
So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude. -
Hi
I want to retrieve the data if the data contains a character or a space or '-' thru select query .
Please help me in writing the combination of 3 with regular expression.
Thanks!!VT wrote:
Hi,
Try this
SELECT *
FROM <TABLE> WHERE REGEXP_LIKE(<COLUMN>, '[a-z -][A-Z -]');cheers
VTThat won't work as it's expecting at least two characters with the first having to be a-z (lower case) or space or "-" followed by A-Z (upper case) or space or "-".
The correct way is either:
[a-zA-Z -]or
[[:alpha:] -]using the alpha set is often preferable as it can work differently with different character sets/languages rather than restricting to just the a-zA-Z ranges.
Generating a reference for your own database characterset/language can be useful...
SQL> select level-1 as asc_code, decode(chr(level-1), regexp_substr(chr(level-1), '[[:print:]]'), CHR(level-1)) as chr,
2 decode(chr(level-1), regexp_substr(chr(level-1), '[[:graph:]]'), 1) is_graph,
3 decode(chr(level-1), regexp_substr(chr(level-1), '[[:blank:]]'), 1) is_blank,
4 decode(chr(level-1), regexp_substr(chr(level-1), '[[:alnum:]]'), 1) is_alnum,
5 decode(chr(level-1), regexp_substr(chr(level-1), '[[:alpha:]]'), 1) is_alpha,
6 decode(chr(level-1), regexp_substr(chr(level-1), '[[:digit:]]'), 1) is_digit,
7 decode(chr(level-1), regexp_substr(chr(level-1), '[[:cntrl:]]'), 1) is_cntrl,
8 decode(chr(level-1), regexp_substr(chr(level-1), '[[:lower:]]'), 1) is_lower,
9 decode(chr(level-1), regexp_substr(chr(level-1), '[[:upper:]]'), 1) is_upper,
10 decode(chr(level-1), regexp_substr(chr(level-1), '[[:print:]]'), 1) is_print,
11 decode(chr(level-1), regexp_substr(chr(level-1), '[[:punct:]]'), 1) is_punct,
12 decode(chr(level-1), regexp_substr(chr(level-1), '[[:space:]]'), 1) is_space,
13 decode(chr(level-1), regexp_substr(chr(level-1), '[[:xdigit:]]'), 1) is_xdigit
14 from dual
15 connect by level <= 256
16 /
ASC_CODE C IS_GRAPH IS_BLANK IS_ALNUM IS_ALPHA IS_DIGIT IS_CNTRL IS_LOWER IS_UPPER IS_PRINT IS_PUNCT IS_SPACE IS_XDIGIT
0 1
1 1
2 1
3 1
4 1
5 1
6 1
7 1
8 1
9 1 1
10 1 1
11 1 1
12 1 1
13 1 1
14 1
15 1
16 1
17 1
18 1
19 1
20 1
21 1
22 1
23 1
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
32 1 1 1
33 ! 1 1 1
34 " 1 1 1
35 # 1 1 1
36 $ 1 1 1
37 % 1 1 1
38 & 1 1 1
39 ' 1 1 1
40 ( 1 1 1
41 ) 1 1 1
42 * 1 1 1
43 + 1 1 1
44 , 1 1 1
45 - 1 1 1
46 . 1 1 1
47 / 1 1 1
48 0 1 1 1 1 1
49 1 1 1 1 1 1
50 2 1 1 1 1 1
51 3 1 1 1 1 1
52 4 1 1 1 1 1
53 5 1 1 1 1 1
54 6 1 1 1 1 1
55 7 1 1 1 1 1
56 8 1 1 1 1 1
57 9 1 1 1 1 1
58 : 1 1 1
59 ; 1 1 1
60 < 1 1 1
61 = 1 1 1
62 > 1 1 1
63 ? 1 1 1
64 @ 1 1 1
65 A 1 1 1 1 1 1
66 B 1 1 1 1 1 1
67 C 1 1 1 1 1 1
68 D 1 1 1 1 1 1
69 E 1 1 1 1 1 1
70 F 1 1 1 1 1 1
71 G 1 1 1 1 1
72 H 1 1 1 1 1
73 I 1 1 1 1 1
74 J 1 1 1 1 1
75 K 1 1 1 1 1
76 L 1 1 1 1 1
77 M 1 1 1 1 1
78 N 1 1 1 1 1
79 O 1 1 1 1 1
80 P 1 1 1 1 1
81 Q 1 1 1 1 1
82 R 1 1 1 1 1
83 S 1 1 1 1 1
84 T 1 1 1 1 1
85 U 1 1 1 1 1
86 V 1 1 1 1 1
87 W 1 1 1 1 1
88 X 1 1 1 1 1
89 Y 1 1 1 1 1
90 Z 1 1 1 1 1
91 [ 1 1 1
92 \ 1 1 1
93 ] 1 1 1
94 ^ 1 1 1
95 _ 1 1 1
96 ` 1 1 1
97 a 1 1 1 1 1 1
98 b 1 1 1 1 1 1
99 c 1 1 1 1 1 1
100 d 1 1 1 1 1 1
101 e 1 1 1 1 1 1
102 f 1 1 1 1 1 1
103 g 1 1 1 1 1
104 h 1 1 1 1 1
105 i 1 1 1 1 1
106 j 1 1 1 1 1
107 k 1 1 1 1 1
108 l 1 1 1 1 1
109 m 1 1 1 1 1
110 n 1 1 1 1 1
111 o 1 1 1 1 1
112 p 1 1 1 1 1
113 q 1 1 1 1 1
114 r 1 1 1 1 1
115 s 1 1 1 1 1
116 t 1 1 1 1 1
117 u 1 1 1 1 1
118 v 1 1 1 1 1
119 w 1 1 1 1 1
120 x 1 1 1 1 1
121 y 1 1 1 1 1
122 z 1 1 1 1 1
123 { 1 1 1
124 | 1 1 1
125 } 1 1 1
126 ~ 1 1 1
127 1
128 Ç 1 1 1
etc.
{code} -
Help in query using regular expression
HI,
I need a help to get the below output using regular expression query. Please help me.
SELECT REGEXP_SUBSTR ('PWRPKG(P/W+P/L+CC)', '[^+]+', 1, lvl) val, lvl
FROM DUAL,(SELECT LEVEL lvl FROM DUAL
CONNECT BY LEVEL <=(SELECT MAX ( LENGTH ('PWRPKG(P/W+P/L+CC)') - LENGTH (REPLACE ('PWRPKG(P/W+P/L+CC)','+',NULL))+ 1) FROM DUAL));
I need the output as
correct result:
==============
val lvl
P/W 1
P/L 2
CC 3
But i tried the above it is not coming the above result. Please help me where i did a mistake.
Thanks in advanceFrank gave you a solution in your other thread. You could simplify it if you are on 11g:
SQL> select * from table_x
2 /
TXT
TECHPKG(INTELLI CC+FRT SONAR)
PWRPKG(P/W+P/L+CC)
select txt,
regexp_substr(
txt,
'(.*\()*([^+)]+)',
1,
column_value,
null,
2
) element,
column_value element_number
from table_x,
table(
cast(
multiset(
select level
from dual
connect by level <= regexp_count(txt,'\+') + 1
as sys.OdciNumberList
order by rowid,
column_value
TXT ELEMENT ELEMENT_NUMBER
TECHPKG(INTELLI CC+FRT SONAR) INTELLI CC 1
TECHPKG(INTELLI CC+FRT SONAR) FRT SONAR 2
PWRPKG(P/W+P/L+CC) P/W 1
PWRPKG(P/W+P/L+CC) P/L 2
PWRPKG(P/W+P/L+CC) CC 3
SQL> SY. -
Query help in regular expression
Hi all,
SELECT * FROM emp11
WHERE INSTR(ENAME,'A',1,2) >0;
Please let me know the equivalent query using regular expressions.
i have tried this after going through oracle regular expressions documentation.
SELECT * FROM emp11
WHERE regexp_LIKE(ename,'A{2}')
Any help in this regard would be highly appreciated .
Thanks,
P Prakashplease go here
Introduction to regular expressions ...
Thanks,
P Prakash -
Urgent!!! Problem in regular expression for matching braces
Hi,
For the example below, can I write a regular expression to store getting key, value pairs.
example: ((abc def) (ghi jkl) (a ((b c) (d e))) (mno pqr) (a ((abc def))))
in the above example
abc is key & def is value
ghi is key & jkl is value
a is key & ((b c) (d e)) is value
and so on.
can anybody pls help me in resolving this problem using regular expressions...
Thanks in advance"((key1 value1) (key2 value2) (key3 ((key4 value4)
(key5 value5))) (key6 value6) (key7 ((key8 value8)
(key9 value9))))"
I want to write a regular expression in java to parse
the above string and store the result in hash table
as below
key1 value1
key2 value2
key3 ((key4 value4) (key5 value5))
key4 value4
key5 value5
key6 value6
key7 ((key8 value8) (key9 value9))
key8 value8
key9 value9
please let me know, if it is not possible with
regular expressions the effective way of solving itYes, it is possible with a recursive regular expression.
Unfortunately Java does not provide a recursive regular expression construct.
$_ = "((key1 value1) (key2 value2) (key3 ((key4 value4) (key5 value5))) (key6 value6) (key7 ((key8 value8) (key9 value9))))";
my $paren;
$paren = qr/
[^()]+ # Not parens
|
(??{ $paren }) # Another balanced group (not interpolated yet)
/x;
my $r = qr/^(.*?)\((\w+?) (\w+?|(??{$paren}))\)\s*(.*?)$/;
while ($_) {
match()
# operates on $_
sub match {
my @v;
@v = m/$r/;
if (defined $v[3]) {
$_ = $v[2];
while (/\(/) {
match();
print "\"",$v[1],"\" \"",$v[2],"\"";
$_ = $v[0].$v[3];
else { $_ = ""; }
C:\usr\schodtt\src\java\forum\n00b\regex>perl recurse.pl
"key1" "value1"
"key2" "value2"
"key4" "value4"
"key5" "value5"
"key3" "((key4 value4) (key5 value5))"
"key6" "value6"
"key8" "value8"
"key9" "value9"
"key7" "((key8 value8) (key9 value9))"
C:\usr\schodtt\src\java\forum\n00b\regex> -
Bracket in Regular Expression constant?
I am a bit puzzled by the behavior I am experiencing in LV 2011. I hope to get some light from experts out there.
I am trying to parse a messy ASCII header file and after having split it into individual lines (strings), I use the "Match Regular Expression" function to remove some of the info before the substantial information.
Some of the strings include square brackets ([, ]), which are special characters for the function, therefore, as documented in the help, one needs to precede them with a backslash.
Example:
I want to parse the following line:
#PR [PR_DEV,I,2]
One way (which I am using because of considerations related to the rest of the header) is the the following:
Note that the first string constant is using "Code Display" whereas the second one is using "Normal Display".
Why did I not put a backslash in front of the bracket in the first string, you may ask? Well, I did, but it disappeared after I typed the other characters. And reverting to "Normal Display" did not restore it.
Of course, the first version does not parse the input string correctly, whereas the second one does it fine.
In other words, the custom display string (which is convenient for cryptic codes such as \s* or to distinguish between space and tab...or simply ENTER tabs!) seems to mess up with the \[ combo (likewise with the \] one).
It is not a huge deal. I can use the "Normal Display" mode, but I tend to think that this qualifies as a hidden "feature". And again, it is still a pain in the ... when dealing with special characters such as tabs, etc...
Solved!
Go to Solution.I think that [ is a special character which needs to be preceded by a backslash, but it is not one of the defined backslash characters (like \s). So, you need to put in two \\ to get one \ while in '\' Codes Display.
You can put in any character by using \xx where the xx is a hex character using only upper case letters for A..F. I converted the strings to byte arrays and tried to see what made the arrays match and the Match work.
Lynn
Maybe you are looking for
-
Hi, I am Meena. I am doing a project using NetBeans and MS-Access. When I run my project a internal framed named login loaded on the jdesktoppane which in JFrame. So in the login internal frame i used two buttons one for Sign-in and another for sign
-
Header Text in Billing Document MANDATORY
HI Gurus, Can you please let me know if we can make the Header text field in the Billing Document---> Header Level as mandatory. Is there any possibility to do that or not? Thankyou, Rakesh Tummala.
-
Resizing imported graphics?
Hi - using FM9. My issue is this - when I import a graphic into graphic frame, I usually have to manually resize the graphic to fit the frame. This degrades the quality of the graphic. I've tried using the Fit in Selected Rectangle option, but it the
-
Problem installing "Adobe Premiere ELements 8 Content"
I have downloaded the two files associated with the additional cont ent for Premiere Elements 8. I have problems when I try to install the file. I am running as administrator. I have tried this on my Windows 7 Pc and Windows XP PC also same error.
-
Blackberry identity installation failed 80003
I keep trying to log in to blackberry app world and it keeps coming up identity installation failed and I can't get in touch with blackberry rim someone please help