Getting non numeric strings using regular expression
Hi Guys ,
I want to get list of string values in table which contains no numeric values .....
I have a string column name A and table name B .
I have written following code , but it seems it is incorrect .
Plz help me out .....
SELECT
A FROM
B
WHERE
regexp_like(A, '([^[:digit:]])'
Thanks in advance ....
96097f0e-f165-463a-a0a2-3d15214c8a3d wrote:
Hi Guys ,
I want to get list of string values in table which contains no numeric values .....
I have a string column name A and table name B .
I have written following code , but it seems it is incorrect .
Plz help me out .....
SELECT
A FROM
B
WHERE
regexp_like(A, '([^[:digit:]])'
Thanks in advance ....
That will give you every one that has at least one non-numeric character, if you want ones which contain no numeric characters then it should be
regexp_like(A,'^[^0-9]*$')
Similar Messages
-
Format string using Regular Expression
Input string output format...
SELECT q'<select ab_c "ABC", efg "EFG" from dual>' str FROM DUAL
Output:
STR
select ab_c "ABC", efg "EFG" from dual
Required output format using regular expression...
STR
select 'ab_c' "ABC", 'efg' "EFG" from dualRegular expressions have many limitations as parsing tools, and you didn't specify the rules you wanted. This expression puts quotes around the non blank string before a quoted string:
SELECT regexp_replace(q'<select ab_c "ABC", efg "EFG" from dual>',
'([^" ]+)( +"[^ ]*")' , '''\1''\2' ) str FROM DUAL;
STR
select 'ab_c' "ABC", 'efg' "EFG" from dual
{code}
It is not robust - a missing " will confuse it, and you should be using bind variables anyway. -
Spliting a large string using regular expression which contain special char
I have huge sting(xml) containing normal character a-z,A-Z and 0-9 as well as special char( <,>,?,&,',",;,/ etc.)
I need to split this sting where it ends with </document>
for e.g.
Original String:
<document>
<item>sdf</item>
<item><text>sd</text</item>
</document>
<document>hi</document>
The above sting has to be splited in to two parts since it is having two document tag.
Can any body help me to resolve this issue. I can use StringTokenizer,String split method or Regular expression api too.manas589 wrote:
I used DOM and sax parser and got few exception. Again i don't have right to change xml. so i thought to go with RegularExpression or some other way where i can do my job.If the file actually comes in lines like what you posted, you should just be able to compare the contents of each line to see if it contains "</document>" or whatever you're looking for. I wouldn't use regex unless I needed another problem.
I got excpetion like: Caused by: org.xml.sax.SAXParseException: The entity "nbsp" was referenced, but not declared.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)So then it isn't even XML.
Edit: sorry, I just realized why you're considering all of these heavy-duty ideas. It's just that you don't know how to break the string into lines. You do it like this:
BufferedReader br = new BufferedReader(new StringReader(theNotXMLString)); -
Filter String using Regular Expression
Hello,
I have an application that monitors serial communication between a PC and device. The message protocol is a byte stream that I convert to a string to parse into pretty messages. The start of the string is always "10 02", but if the string is preceded with another "10" like this "10 10 02" it is part of a message. I've been trying to use a regular expression with the Search and Replace VI. My regex is "[^10]\s10\s02" which almost works but it cuts off part of the message:
Before:
10 03 10 02
After:
10 0 <= missing the "3"
10 02
Here's what I'm doing:
Any ideas on what I'm missing? I've attached a simple example.
Thanks
Message Edited by Derek Price on 02-14-2008 08:37 PM
Attachments:
Filter Beginning Message1.vi 14 KB
FilterMessageRegex1.png 7 KBTry this approach.
Do search and replace on '10\s02' and replace with '\r\n10\s20'
Then do another search and replace on '10\r\n\10\s20' with '10\s10\s20'
See attached.
Randall Pursley
Attachments:
Message Filter.PNG 18 KB -
Dumbfounded by Scanner processing String using regular expression
I was reading Bruce Eckel's book when I came across something interesting: extending Scanner with regular expressions. Unfortunately, I was confronted with an issue that doesn't make much sense to me: if the String that I am scanning contains a hyphen, the Scanner doesn't produce anything. As soon as I take it out, it all works like a charm. Here is my example:
import java.util.Scanner;
import java.util.regex.*;
public class StringScan {
public static void main (String [] args){
String input = "there's one caveat when scanning with regular expressions";
Scanner scanner = new Scanner (input);
String pattern = "[a-z]\\w+";
while (scanner.hasNext(pattern)){
scanner.next(pattern);
MatchResult match = scanner.match();
String output = match.group();
System.out.println(output);
}What could be the reason? I imagined it could be because the hyphen for some reason gets given a special meaning but when I tried escaping it, it still didn't work.Thanks for your prompt reply.
I have figured out what was wrong with my code, by the way. Since a single quote is not a word character, it does not match w+. And as the very first input token does not match, the scanner stops immediately. I rewrote my regex to "[a-z].*" and now it does work. -
Replace a string using regular expression from powershell
I want to replace the following:
'browserName': 'firefox'
with :
'browserName': 'chrome'
then I tried this:
(get-content $conffile) -replace "^('browserName': ')\S+","browserName': 'chrome' |set-content $conffile
But nothing happened.
Could someboby tell me how to write the regular expression here? Thanks a lot.Second person today with the same question.
get-content $conffile |%{$_ -replace "'browserName':\s+'firefox'","'browserName': 'chrome'" | set-content $conffile
\_(ツ)_/ -
How to Capture Multiple Line String using Regular Expression?
Hi,
I have a simple program like this:
What I want to accomplish is to capture everything between >>start and >>end using a single Match Regular Expression node. It seems that setting multiple? to True or False does not help.
I am using LabVIEW 2012.
If it is impossible to capture it using a single node, that is fine. But I want to make sure that I can make full use of this node without combining serveral others.
Thank you!
TailOfGon
Certified LabVIEW Architect 2013
Solved!
Go to Solution.Thank you for the fast response! Your solution worked in the example case
After I saw your post, I was finally able to step forward. But I still wanted to make use of dot notation due to the limitation of characters that match with \w.
I made some more modification to your regular expression then now it seems working for all characters:
>>start((?:\s|.)*)>>end
Thanks!
TailOfGon
Certified LabVIEW Architect 2013 -
Filter Strings using regular expressions
Requirements.
1.I have a table with different names.
2.I input a word(string) through a text box.
3.I filter table using the input string through text box using the code
((DefaultRowSorter)table_customer.getRowSorter()).setRowFilter(RowFilter.regexFilter(regex, indices));
4.regex is obtained as follows.
String regex = "";
String text = txtFilterText.getText();
regex = "^(?i)"text".*"; //for starts with filter
regex = "." + text + ".";//for contains filter
regex = "(?i)["text".*]";//for doesnt start with filter
regex =".*(?i)"text"$";//for end with filter
I need help for doesnt contain and doesnt end with filters.Plz help me out..
Aneesh2. {color:ff0000}Double post{color}
Reply here: http://forum.java.sun.com/thread.jspa?threadID=5231406 -
One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?
How to get the below output using REGULAR EXPRESSIONS??
SQL> ed
Wrote file afiedt.buf
1* CREATE TABLE cus___addresses (full_address VARCHAR2(200 BYTE))
SQL> /
Table created.
SQL> PROMPT Address Format is: House #/Housename, street, City, Zip Code, COUNTRY
House #/Housename, street, City, Zip Code, COUNTRY
SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
1 row created.
SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
1 row created.
SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
1 row created.
SQL> SELECT * FROM cus___addresses;
FULL_ADDRESS
1, 3rd street, Lansing, MI 49001, USA
3B, fifth street, Clinton, OK 74103, USA
Rose Villa, Stanton Grove, Murray, TN 37183, USA
SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AMHi,
user12240205 wrote:
... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
'.*' means "0 or more of any character".
'\D*' means "0 or more non-digits".
The whole expression, '.*(\d{5})\D*' means:
a. 0 or more characters (any characters)
b. 5 digits
c. 0 or more non-digits.
'\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone." -
Using regular expressions to get a customized output
Hi,
I have a string/varchar variable with the data ',a,b,c,' in it.
I want the display as follows:
a
b
c
I would like to get the similar output using regular expressions.
How do I get this output using REGEXP_REPLACE or REGEXP_SUBSTR?
Please do the needful.
Thanks & Regards,
RakshitI remember that, however if we look closer, that one has a little flaw: The 2nd row should be null, because ",," indicates an empy field. The MODEL clause solution works just fine in this case:
with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)
-- end of sample data
SELECT col_new
FROM t
MODEL
PARTITION BY (ROWNUM rn)
DIMENSION BY (0 dim)
MEASURES(col1, col1 col_new)
RULES ITERATE(99) UNTIL (ITERATION_NUMBER = LENGTH(REGEXP_REPLACE(col1[0], '[^,]')))
(col_new[ITERATION_NUMBER] = REPLACE(REGEXP_SUBSTR(col1[0], '(^|,)[^,]*', 1, ITERATION_NUMBER+1), ','))
COL_NEW
aaaa
bbbb
cccc
dddd
eeee
ffff
7 Zeilen ausgewählt.Update: I had this nagging feeling that I missed something, and there it was. If you want to see what the problem with my solution is, change the example to
with t as (select ',aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)So I went back and tried to fix BlueShadows approach. Here it is:
with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' txt from dual)
-- end of sample data
SELECT REPLACE(REGEXP_SUBSTR(',' || txt, ',[^,]*', 1, level), ',') col_new
FROM t
CONNECT BY level <= length(regexp_replace(txt,'[^,]*'))+1
;C. -
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. -
Using Regular Expressions to replace Quotes in Strings
I am writing a program that generates Java files and there are Strings that are used that contain Quotes. I want to use regular expressions to replace " with \" when it is written to the file. The code I was trying to use was:
String temp = "\"Hello\" i am a \"variable\"";
temp = temp.replaceAll("\"","\\\\\"");
however, this does not work and when i print out the code to the file the resulting code appears as:
String someVar = ""Hello" i am a "variable"";
and not as:
String someVar = "\"Hello\" i am a \"variable\"";
I am assumming my regular expression is wrong. If it is, could someone explain to me how to fix it so that it will work?
Thanks in advance.Thanks, appearently I'm just doing something weird that I just need to look at a little bit harder.
-
How to get year value using regular expression
Hi,
I have a different format of date such as 2004-01-03, 2003/01, 05/06/2005, 06-05-2007
How can I get only the year value using regular expression? The year value is always in 4 digits
Thanks in advancesabre150 wrote:
JosAH wrote:
\d{4}Is this the Jos I knew who poured scorn on anything to do with regex? Is this the Jos I knew who said that the 'pimping lemon' stopped regex being of any real use?It wasn't me; honest, I'm innocent: one of my parrots walked over my keyboard; I wouldn't be able to type such nonsense; naughty parrot! No cookie!
kind regards,
Jos
ps. regexes can only survive the baby-pumping-lemma; they all die a horrible death with the real-men-pumping lemma! So there. -
Changeparticular characters in a string by using regular expressions ...
Hello Everyone,
I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
Is it possible by using regular expressions in oracle ?
Can you give me some clues ?
Thank youSSU wrote:
Hello Everyone,
I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
Is it possible by using regular expressions in oracle ?
Can you give me some clues ?
Thank you
SQL> SELECT
2 regexp_replace('sdfsdf Sdfdfs Sdfd','s|S','X') from dual;
REGEXP_REPLACE('SD
XdfXdf XdfdfX XdfdRegards,
Achyut -
String extract using regular expression
Hi
I have text like this "<a>45</a><ct>Hi</ct><R>45 85</R><H>Here</H>" .I want to extract using regular expression or any techniques the text between <R> and </R> also need to replace the space with pipe between 45 and 85 like "45|85"
Edited by: vishnu prakash on Mar 2, 2012 4:42 AMHi,
Here's one way:
REPLACE ( REGEXP_REPLACE ( txt
, '.*<R>(.*)</R>.*'
, '\1'
, '|'
)This assumes there is only one <R> tag in txt.
Always say which version of Oracle you're using. The expression above will work in Oralce 10 and up, but starting in Oracle 11 you can use REGEXP_SUBSTR rather than the less intuitive REGEXP_REPLACE.
Edited by: Frank Kulash on Mar 2, 2012 7:48 AM
Maybe you are looking for
-
Hi Gurus, This is the error I am getting when I open WebDynpro Page of Content Administration. <b>The initial exception that caused the request to fail, was: com.sap.tc.webdynpro.repository.RepositoryException: Did not find application 'c
-
Can a Windows Hard Drive be reformatted for MAC?
I have a windows computer that I do not use anymore, that I put a 2nd Hard Drive in it. I was wondering if it is possible to install it in my G5 and format it to use it with MAC?
-
Did apple solve the distribution list issue on lion
In Snow-Leo there was a very annoying problem on mail distribution-lists, if the people on the list had multiple email adresses. More information here: https://discussions.apple.com/thread/2398363?start=0&tstart=0 Does anybody know, whether this is s
-
I have an iMac and a Macbook Pro. Downloaded Mountain Lion. Could no longer send mail messages. Checked my Mail preferences and they were correct. Icalled my ISP and they tried to help make it work by setting some new preferences Did not work. Took M
-
Diff. bet. JSP String ( %! String) and Java String.
Hi all, Think this is one of the basic Questions. I want to know the basic diff. between <%!String a=10; %> and <%String a=10; %> programmatically, with an example. Bye Sreedhar