Extraction of Numbers from string in oracle
Dear All,
I have a AplhaNumeric field in my source table which holds the string with numbers and caharcters .i need to extract only numbers and to load into the target table which of number type.
can any one suggest me about how to do this?
regards
kumar
Hi ,
I have a table called smitems with column smitmqtyremarks which holds alpha numeric characters .nearly 180 records exists in this table.
i need extract numbers for this field and load into my target tables.
here i am giving sample rows for this field :
smitmqtyremarks
13 قطعة
4 لحاف
31 قطعة
120 قطعة
57 قطعة
110 قطعة
127قطعة
169 قطعة
12 مفرش
10 مفارش
110 قطعة
170 قطعة
20 خرطوشة
28 قطعة
60قطعة
70 قطعة
80 لعبة
70 قطعة
20 قطعة
60 قطعة
50 قطعة
10 رولات
4 رولات
35 دسته
50دستة
7 رول
3 اثواب قماش
خمسة خرطوشة سجائر
50 جاكت حريمى ورجالى
10 رول اقمشة 4 دسته
420 جوارب اطفال
60 خرطوشة سجائر
12 رول
15 خرطوشة
110 علبة
45 قطعة
40 قطعة
44 قطعة
22 قطعة
3 خرطوشة
468 قطعة
38 قطعة
80 رول قماش
2 رول
6 رول اقمشة
13 رول اجنبى الصنع
100 دسته صينى الصنع
18 رولات ملابس
10دسته
90قطعة
33 قطعة
39 قطعة
42 قطعة
300 ايشارب
500 قطعة
19000 ك 0ج
607 قطعة
24 قطعة
45 قطعة
40 اروسه
5 رول اقمشة اجنبية الصنع
75 قطعة
5 قطعة
4 رول
26 قطعة
50قطعة
105 قطعة
650 جرام
65 قطعة
50 خرطوشة
4 خرطوشة
80 قطعة
100 بنطلون
500 قطعة
40 قطعة
42قطعة
1 خرطوشة
14 قطعة
80 قطعة
7 خرطوشة سجائر
230 لمبة
50 قطعة
50قطعة تليفون
14 كرتونة
4 كرتونة احذية
17 كرتونة خزف
22 لحاف
16كرتونة ادوات صحية
8كرتونة
28 كرتونة
2كرتونة
15كرتونة
115 قطعة
6448
1937قطعة
1937 قطعة
2628كجم
6.980طن
9 كرتونة
18 شفاط
صواميل حديد
3كرتونة +20 قطعة
39.480طن ق.غ سيارات
25كرتونة مصنوعات خزفية
50بنطلون
8 كرتونة كلبسات
20كرتونة اكسسوار حريمى
279كرتونة لحوم
38 اطار كاوتش
10كرتونة
4كرتونة
10كيلو
عدد5 ماكينات
41سيارة
سيارة
90 قطعة ملابس
22250كجم
1793كجم
1371كرتونة زجاج
مستندى
252شاشة
5كرتونة
320قطعة
45خرطوشة
98 قطعة
10لفات
25كجم
320كجم
5كراتين
47طرد
50قطعة
117كجم
1200 قطعة ملابس
5كجم
75جهاز
40قطعة
5كراتين
10كجم
250ق
200ق
200 توب
20لفة
30لفة
2دستة
95قطعة
70قطعة
57523طن طلمبات مياه
43732كجم
755كرتونة
10.645طن
1537طرد
11751كجم
مكبس
77426.80متر
2600قطعة
339طن
15120كجم
مختلفة
267طرد
1200كجم
189عبوة
499كرتونة
10000كجم
960طرد
15.770كجم
111قطعة
174طرد
22000كجم
473000علبة
6720كجم
145خرطوشة
2500طن
3660كجم
27824كجم
8682كجم
14000كجم
6400كجم
133كرتونة
2738كجم
the characters are in arabic here.
hope it clears my issue.
please suggest me the right query for this to get only numbers
thanks
kumar
Similar Messages
-
Extract 2 characters from string
Hello,
Can anyone help to create a formula to extract 2 characters from the left of "pp" in a field using CR XI?
Field = {MainEstimateDetails.JobDescription} (string)
Sample string details:
"Annual Report 96pp & Cover 12345" - want to be able to show only 96 (from 96pp)
"CTP A4 4pp" - want to be able to show only 4 (from 4pp)
The string length is variable and the "pp" will be in different places each time.
It is probably very simple, but I cannot get itHi,
You can use the InStr function for this. InStr returns the position of the string your are looking for.
NumberVar myPosition;
If InStr ({MainEstimateDetails.JobDescription}, "pp") > 0 Then
myPosition := InStr ({MainEstimateDetails.JobDescription}, "pp")
Else myPosition := 0;
If myPosition <> 0 Then
{MainEstimateDetails.JobDescription} [(myPosition - 2) To (myPosition - 1)]
Else "";
This is a bit longer than I would normally do it but... I use Instr to check if the field has "pp" in it. If it does it will return the character position in the field and I pass that to my variable myPosition.
If myPosition has a value then it parses out the two characters before "pp".
Good luck,
Brian -
Extract the numbers in string using regex
Hi,
How to extract the numers in string using regex?.
Already i tried split up the string using [\\s]
For ex: "Uting Tatk and Window Panet 15"
it gives the ans 15.
if the string is
For ex: "Uting Tatk and Window Panet 15 New!"
i can't find the number.
so plz give me some idea to get the number frm String.
ThanksI am developing a java project to extract Table of
content in a particular
PDF.
i extracted all topics.
then i want 2 extract page number from dat extracted
TOC.
if the TOC ends with number then i can easily find
out the number
but in vain if the TOC ends with like this
"Uting Tatk and Window Panet 15 New!".
i could n't find the page number.What will you do if it says:
"15 ways to find topics 42 new" -
Need a way to extract substring from string in oracle
Hi all,
I have one requirement related to extracting string from a paramater.
suppose the string may like this in various format
string:= 'This my string <Rid//problem/123456>'
or
string:= '<Rid//problem/123456> This my string'
or
string:= ' This is <Rid//problem/123456> my string'
Now my requirement is i need to extract 123456 using pl/sql block.
is there any way in oracle to get this thing done.
Thanks n regards
LaxmanHi,
What version of Oracle ?
How do you delimit the string to extract ?
- always between the last / and before the >
- the last string mande of number ?
- the first string made of number ?
Here are 3 possible answers :SQL> with s as (
2 select 'This my string <Rid//problem/123456>' s from dual
3 union all select '<Rid//problem/123456> This my string' from dual
4 union all select ' This is <Rid//problem/123456> my string' from dual
5 )
6 select s.s,
7 regexp_replace(s,'^.*/([0-9]*).*$','\1') r1,
8 regexp_replace(s,'^[^0-9]*(.*?)[^0-9]*$','\1') r2,
9 regexp_replace(s,'^.*/(.*?)>.*$','\1') r3
10 from s ;
S R1 R2 R3
This my string <Rid//problem/123456> 123456 123456 123456
<Rid//problem/123456> This my string 123456 123456 123456
This is <Rid//problem/123456> my string 123456 123456 123456If you're on 10g or more...
Of course it also works in PL/SQL :SQL> l
1 declare
2 r1 varchar2(50) := 'This my string <Rid//problem/123456>';
3 r2 varchar2(50) := '<Rid//problem/123456> This my string';
4 r3 varchar2(50) := ' This is <Rid//problem/123456> my string';
5 r1b varchar2(50);
6 r2b varchar2(50);
7 r3b varchar2(50);
8 begin
9 r1b := regexp_replace(r1,'^.*/([0-9]*).*$','\1') ;
10 r2b := regexp_replace(r2,'^[^0-9]*(.*?)[^0-9]*$','\1') ;
11 r3b := regexp_replace(r3,'^.*/(.*?)>.*$','\1') ;
12 dbms_output.put_line('1 : '||r1||' -> '||r1b);
13 dbms_output.put_line('2 : '||r2||' -> '||r2b);
14 dbms_output.put_line('3 : '||r3||' -> '||r3b);
15* end;
SQL> /
1 : This my string <Rid//problem/123456> -> 123456
2 : <Rid//problem/123456> This my string -> 123456
3 : This is <Rid//problem/123456> my string -> 123456
PL/SQL procedure successfully completed.Edited by: Nicosa on Jul 23, 2010 3:22 PM -
Parsing and extraction of numbers from select lines in a string
hey guys, i've been running into some issues with my code and i was wondering if you could help me out. currently what i've done is take an xml document returned from a server, put it into a string, and then select specific lines from that string, from which i will extract numbers. here's the string
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:census1="tag:govshare.info,2005:rdf/census/details/100pct/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:census="http://www.rdfabout.com/rdf/schema/census/">
<rdf:Description rdf:about="http://www.rdfabout.com/rdf/usgov/geo/census/zcta/90041/censustables">
<census1:totalPopulation>
<rdf:Description>
<dc:title>SEX BY AGE (P012001)</dc:title>
<census1:female>
<rdf:Description>
<census1:_40To44Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1131</census1:_40To44Years>
<census1:_62To64Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">327</census1:_62To64Years>
<census1:_10To14Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">875</census1:_10To14Years>
<census1:under5Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">864</census1:under5Years>
<census1:_18And19Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">592</census1:_18And19Years>
<census1:_67To69Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">307</census1:_67To69Years>
<census1:_55To59Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">689</census1:_55To59Years>
<census1:_22To24Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">600</census1:_22To24Years>
<census1:_75To79Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">450</census1:_75To79Years>
<census1:_80To84Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">331</census1:_80To84Years>
<census1:_25To29Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">932</census1:_25To29Years>
<census1:_15To17Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">534</census1:_15To17Years>
<census1:_30To34Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1035</census1:_30To34Years>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">14540</rdf:value>
<census1:_50To54Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">970</census1:_50To54Years>
<census1:_45To49Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1038</census1:_45To49Years>
<census1:_5To9Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">949</census1:_5To9Years>
<census1:_60And61Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">261</census1:_60And61Years>
<census1:_21Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">264</census1:_21Years>
<census1:_70To74Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">482</census1:_70To74Years>
<census1:_65And66Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">208</census1:_65And66Years>
<census1:_35To39Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1026</census1:_35To39Years>
<census1:_20Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">285</census1:_20Years>
<census1:_85YearsAndOver rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">390</census1:_85YearsAndOver>
</rdf:Description>
</census1:female>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">27864</rdf:value>
<census1:male>
<rdf:Description>
<census1:_40To44Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1077</census1:_40To44Years>
<census1:_62To64Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">270</census1:_62To64Years>
<census1:_10To14Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">872</census1:_10To14Years>
<census1:under5Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">862</census1:under5Years>
<census1:_18And19Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">511</census1:_18And19Years>
<census1:_67To69Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">258</census1:_67To69Years>
<census1:_55To59Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">647</census1:_55To59Years>
<census1:_22To24Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">569</census1:_22To24Years>
<census1:_75To79Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">252</census1:_75To79Years>
<census1:_80To84Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">183</census1:_80To84Years>
<census1:_25To29Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">969</census1:_25To29Years>
<census1:_15To17Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">525</census1:_15To17Years>
<census1:_30To34Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1024</census1:_30To34Years>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">13324</rdf:value>
<census1:_50To54Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">822</census1:_50To54Years>
<census1:_45To49Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">987</census1:_45To49Years>
<census1:_5To9Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">974</census1:_5To9Years>
<census1:_60And61Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">215</census1:_60And61Years>
<census1:_21Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">287</census1:_21Years>
<census1:_70To74Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">320</census1:_70To74Years>
<census1:_65And66Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">155</census1:_65And66Years>
<census1:_35To39Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1140</census1:_35To39Years>
<census1:_20Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">257</census1:_20Years>
<census1:_85YearsAndOver rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">148</census1:_85YearsAndOver>
</rdf:Description>
</census1:male>
</rdf:Description>
</census1:totalPopulation>
</rdf:Description>
</rdf:RDF>now my first attempt at pulling this off worked just fine, but only for the female demographics, since the tags for female and male are identical (only the numbers/data is different) and my parser would stop after reaching the first round of tags specified.
here's part of my code for that section, located in the main (response is the xml string returned from server):
while ((temp = in.readLine()) != null)
response += temp + "\n";
temp = null;
in.close ();
int left = response.indexOf("<census1:under5Years rdf:datatype=\"http://www.w3.org/2001/XMLSchema#integer\">");
int right = response.indexOf("</census1:under5Years>");
// pull out the text inside the parens
String parsed = response.substring(left+77, right);
double parseddub = Double.parseDouble(parsed);
//divide the group Under5Years into Under12Mo and 1to4Yr
double Group1Adub = parseddub*.25;//25% for Under12Mo
Group1Adub = Math.ceil(Group1Adub);
int Group1A =(int)Group1Adub;
double Group1Bdub = parseddub*.75;//75% for 1to4Yr
Group1Bdub = Math.ceil(Group1Bdub);
int Group1B =(int)Group1Bdub;
//..need to basically duplicate this for 3 other age groups
int Group1 = Group1A;
System.out.println("Server response:\n" + "Female");
System.out.println("Under 12 Months: " + Group1);now basically, everything works great for the female data, but i would like to somehow loop this or selectively parse by line and then extract information from those selected lines. any thoughts? i would really appreciate some insight thanks.lol no offense taken. sorry for the confusion, please disregard my earlier statements... :)
i actually was able to get the thing working, i just didn't quite understand what i was doing at first.
however, i noticed that the regex only handles the first four lines of each group (male and female). i was wondering if there was a way to do it that's non-sequential?
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:census1="tag:govshare.info,2005:rdf/census/details/100pct/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:census="http://www.rdfabout.com/rdf/schema/census/">
<rdf:Description rdf:about="http://www.rdfabout.com/rdf/usgov/geo/census/zcta/90041/censustables">
<census1:totalPopulation>
<rdf:Description>
<dc:title>SEX BY AGE (P012001)</dc:title>
<census1:female>
<rdf:Description>
<census1:_40To44Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1131</census1:_40To44Years>
<census1:_62To64Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">327</census1:_62To64Years>
-<census1:_10To14Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">875</census1:_10To14Years>
-<census1:under5Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">864</census1:under5Years>
<census1:_18And19Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">592</census1:_18And19Years>
<census1:_67To69Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">307</census1:_67To69Years>
<census1:_55To59Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">689</census1:_55To59Years>
<census1:_22To24Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">600</census1:_22To24Years>
<census1:_75To79Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">450</census1:_75To79Years>
<census1:_80To84Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">331</census1:_80To84Years>
<census1:_25To29Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">932</census1:_25To29Years>
-<census1:_15To17Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">534</census1:_15To17Years>
<census1:_30To34Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1035</census1:_30To34Years>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">14540</rdf:value>
<census1:_50To54Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">970</census1:_50To54Years>
<census1:_45To49Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1038</census1:_45To49Years>
-<census1:_5To9Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">949</census1:_5To9Years>
<census1:_60And61Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">261</census1:_60And61Years>
<census1:_21Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">264</census1:_21Years>
<census1:_70To74Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">482</census1:_70To74Years>
<census1:_65And66Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">208</census1:_65And66Years>
<census1:_35To39Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1026</census1:_35To39Years>
<census1:_20Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">285</census1:_20Years>
<census1:_85YearsAndOver rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">390</census1:_85YearsAndOver>
</rdf:Description>
</census1:female>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">27864</rdf:value>
<census1:male>
<rdf:Description>
<census1:_40To44Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1077</census1:_40To44Years>
<census1:_62To64Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">270</census1:_62To64Years>
-<census1:_10To14Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">872</census1:_10To14Years>
-<census1:under5Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">862</census1:under5Years>
<census1:_18And19Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">511</census1:_18And19Years>
<census1:_67To69Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">258</census1:_67To69Years>
<census1:_55To59Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">647</census1:_55To59Years>
<census1:_22To24Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">569</census1:_22To24Years>
<census1:_75To79Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">252</census1:_75To79Years>
<census1:_80To84Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">183</census1:_80To84Years>
<census1:_25To29Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">969</census1:_25To29Years>
-<census1:_15To17Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">525</census1:_15To17Years>
<census1:_30To34Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1024</census1:_30To34Years>
<rdf:value rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">13324</rdf:value>
<census1:_50To54Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">822</census1:_50To54Years>
<census1:_45To49Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">987</census1:_45To49Years>
-<census1:_5To9Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">974</census1:_5To9Years>
<census1:_60And61Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">215</census1:_60And61Years>
<census1:_21Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">287</census1:_21Years>
<census1:_70To74Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">320</census1:_70To74Years>
<census1:_65And66Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">155</census1:_65And66Years>
<census1:_35To39Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">1140</census1:_35To39Years>
<census1:_20Years rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">257</census1:_20Years>
<census1:_85YearsAndOver rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">148</census1:_85YearsAndOver>
</rdf:Description>
</census1:male>
</rdf:Description>
</census1:totalPopulation>
</rdf:Description>
</rdf:RDF> using the regular expression, i can parse the string, but what i really need is to only parse the 8 lines designated, and they are not in sequential order, which makes it somewhat problematic.
the format of the output i want to get should be as in the following example (female: under5, 5to9, 10to14, 15to17):
[864, 949, 875, 534]
same format for male of course. i'm just not sure how to edit the regex so that it can select only the lines i'm concerned with...? thanks so much i really appreciate this. -
How to extract the Datetime from string?
Hello FOlks,
I have the sample data whichi is a string and it contains DateTime part inside it. I worked through half way but am not sure how to get the other part.
The sample data is
Note Added by AARON HILTON at 05/26/2010 14:53 MONEY NOTE ENTERED
Note Added by DEBBIE BILL at 11/16/2009 23:12 MONEY ENTERED
I tried using
substr(d.assignee_note, INSTR(d.assignee_note,'at')+2,length(d.assignee_note)) but it did not have the desired results.
How to just extract the datetime part i.e. 11/16/2009 23:12If your sample data is representative for all the data, you could also try a regular expression:
SQL> -- generating sample data, pretending it's stored in a column called str in a table called t:
SQL> with t as (
2 select 'Note Added by AARON HILTON at 05/26/2010 14:53 MONEY NOTE ENTERED' str from dual union
3 select 'Note Added by DEBBIE BILL at 11/16/2009 23:12 MONEY ENTERED' from dual
4 )
5 --
6 -- actual query:
7 --
8 select trim(regexp_replace(str, '[[:alpha:]]')) str
9 , to_date(trim(regexp_replace(str, '[[:alpha:]]')), 'mm-dd-yyyy hh24:mi') dt
10 , to_timestamp(trim(regexp_replace(str, '[[:alpha:]]')), 'mm-dd-yyyy hh24:mi') ts
11 from t;
STR DT TS
05/26/2010 14:53 26-05-2010 14:53:00 26-05-10 14:53:00.000000000
11/16/2009 23:12 16-11-2009 23:12:00 16-11-09 23:12:00.000000000
2 rows selected.where column STR is, well, a string, DT will turn your string into date datatype and TS will turn it into a timestamp.
It isn't clear how you want to extract the datetime part, but it really matters... -
Extract balanced parantheses from String
Hi community,
I am getting back to work on LabVIEW after long.
Currently implementing an algorithm and I need to work with tree like structures presented in the form of strings with parantheses.
So, for example, a string such as A(B(c,d),P(q,r),U(V(w),X(y,z,o))) has a tree with root node A, and there are three children of A, namely B, P, U, and all of them also represent a tree (sub-tree of the original tree A). So that, B is the root of the sub-tree where c and d are the two nodes. U also has two children that represent individual sub-trees, namely V (with one child) and X (with three children).
Although, there is one detail, which may actually help the process a bit. The trees are simplified, so that all the nodes that represent some tree (or sub-tree) are just called S.
To extract all these trees, I am going to check one element at a time and then build the sub-trees one by one.
Just thought to ask here if someone has a better idea (or if some function from OpenG may help here if someone has done something similar). Always ready to learn!
Thanks ahead!
VaibhavOk, I just finished the function to validate the input string, extract all the valid sub-trees and list them.
The VI and the required Sub-VI are in the attachment.
This is just to show what output do I need. Any suggestions to improvements are most welcome.
And if someone finds this solution as useful, I would appreciate acknowledgement of that too (Kudos ).
But my main objective is to know how this could be done in a smarter way.
Try to play with the function with different valid and invalid tree automata strings. Be careful with the root symbol.
In the above post I used "S" as the root symbol, and in the VI, I am using "X" by default. So just change either of them.
Try for example,
X(a,b) - valid - 1 tree
X(X(a,b)) - valid - 2 sub-trees
X((a,b)) - invalid
X(a,b)) - invalid
X(X(a,b) - invalid
X(X(a), X(X(b)),X(c,X(d )) ) - valid (it will remove the unnecessary spaces that the user might add mistakenly) - 6 sub-trees.
Could I get these results through regular expressions?
Remark: I didn't put small checks like if the user gives a multi-char string as the Root symbol or things like that, just to implement quickly. I assume the user will not make deliberate mistakes like this.
In the front panel of the main VI (Validate and Extract Sub-trees.VI), you may ignore the array A2, as it was mainly for my debugging purposes. The array A2 is filled while the program runs, and you may see my logic in those cells. But ignore otherwise.
Cheers!
[Edited 03/24/2014: Attachment with private information removed at poster's request]
Vaibhav -
Extracting numeric data from string
Dear all,
how can i extract a numeric part of a Varchar2 column..
the data is
transaction 111.98 sucess
gsdhgadg 52365.878 hdfjhfd
ttqweqwg3321.7676jdshfjhsf
from all the above strings i want to extract 111.98 ,52365.878 ,3321.7676
how can i do it in teh most efficient way.. is theer any analytical function inplace for doing this?
please help..edogt wrote:
hi,
this is my solution:
declare
anumber varchar2(100) ;
text varchar2(100) := 'transaction. 111.98 sucess' ;
begin
anumber := regexp_substr(text,'[[:digit:]]+(\.[[:digit:]]+)*');
dbms_output.put_line(anumber);
end ;Which doesn't work if you test it against the OP's latest requirement...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'transaction 111.98 sucess' as txt from dual
2 union select 'gsdhgadg 52365.878 hdfjhfd' from dual
3 union select 'ttqweqwg3321.7676jdshfjhsf' from dual
4 union select 'IT2 Power Resis;UPI 2.4900;QTY10' from dual)
5 -- end of test data
6 select txt, regexp_substr(txt, '[0-9]+\.[0-9]+') as num
7 , regexp_substr(txt,'[[:digit:]]+(\.[[:digit:]]+)*') as num2
8* from t
SQL> /
TXT NUM NUM2
IT2 Power Resis;UPI 2.4900;QTY10 2.4900 2
gsdhgadg 52365.878 hdfjhfd 52365.878 52365.878
transaction 111.98 sucess 111.98 111.98
ttqweqwg3321.7676jdshfjhsf 3321.7676 3321.7676
SQL>P.S. you should wrap your code with {noformat}{noformat} tags so that it's displayed properly. ;) -
Extract number value from string
Hi,
I am getting a string value like bellow.
'2222jhone'
'123344Sam'
'11Tim'
i want to extract only number value.Can anybody help to prepare reg expression.
TahnksYou NEVER want to use REGEXP_REPLACE when looking to query fields with numbers only because you are actually changing the data by removing or replacing with something that was not originally in the dataset. Use REGEXP_LIKE - SEE BELOW.
SELECT <FieldNames>
WHERE REGEXP_LIKE(<FieldName>, '^[[:digit:]]+$')
--This will only return fields that contain NUMBERS ONLY. -
Truncate numbers from string field
Afternoon all,
This time I'd like to extract only 2 strings out of a string field. The field is of sales area which contains numbers and letters. For example, Scotland is given a number 01, West midlands is 02, Ireland however is given IR.
however, the field which holds the information is like, 012, where 01 is the area number and 2 is type of area number.
The information which we are interested in is first two strings.
I have tried this in the formula given below but it doesn't work, it states a field is required
If hasvalue({?Sales Area}) then
totext(Minimum({slslsp.slr_slsperson}[1 to 2])) + " - " +
totext(Maximum({slslsp.slr_slsperson}[1 to 2]))
else
"n/a"
Should I be using a truncate and if yes then how?
P.S. This is to show only the sales area number or text if selected under a parameter. The values of the parameter will stay the same. In other words it is just to show in the report.
Many thanks once again
Regards
JehanzebIs it a range parameter? If so try this
If hasvalue({?Sales Area}) then
totext(Minimum({slslsp.slr_slsperson})[1 to 2]) + " - " +
totext(Maximum({slslsp.slr_slsperson})[1 to 2])
else
"n/a"
regards,
Raghavendra.G
Edited by: Raghavendra Gadhamsetty on Jan 16, 2009 4:16 PM -
Extract min timestamp from string
Hello all,
I am trying to query the minimum datetime from a column that is stored as nvarchar(max). There a a few tricky things with this query (at least for me)
- There is more than just the date being stored within each record.
-The position of the datetime is relative- although it does always appear in the format '**(DD-MM-YY at HH:MM PM'
-There are multiple datetimes stored in each record-so not only do I need to locate and capture where there is a datetime, I need to find the minimum datetime within the record
- I can't just change the format that the data is stored in- there is over a decade of information that is stored this way.
Please Help
The column is called 'hdresp'
Here is sample data:
**(03-Apr-14 at 09:44 AM email sent) -- Billy Bob: Upgrade ordered. **(02-Apr-14 at 04:16 PM email sent) -- Sammy Richards: I can give you another cable to if you think that will help but it just might be time for an upgrade. If
you want to go that route I have to ask that you submit another request for New Hardware. **(02-Apr-14 at 03:17 PM email sent) -- Paul Smith: Michael Stop by my desk when you have a second.
-What i would like to end up with is a query that identifies '02-Apr-14 at 3:17 PM' as the minimum time and converts it to 'YYYY-MM-DD HH:MM:SS' -for example '2014-04-02 15:17:00'
Thanks!Thank you everyone for your help!
I ended up using this to extract and convert the minimum time from a string:
SELECT CONVERT(datetime, REPLACE(LEFT(RIGHT(hdresp, PATINDEX('%(**%', REVERSE(hdresp)) - 1), 21), 'at ', ''))
from tblhdmain
where hdindex = 211458
Which gave me the result:
2014-04-02 15:17:00.000 -
Separation of Numbers from string
Hi All,
In my project i have a requirement where i need to remove the numerical values from the given string ...
For ex My input:CLWMEK0299
Expected Output : CLWMEK
Kindly please let me know ASAP... '
Thanks and regards,
Sudarshan
Edited by: Sudarshan on Mar 28, 2012 9:51 PMLook at this SQLPLUS:
SQL> select regexp_replace('123abc', '[0-9]','') from dual;
REG
abc
SQL> select regexp_replace('1a7bc', '[0-9]','') from dual;
REG
abc
SQL> create table T ( Text varchar2(20));
Table created.
SQL> insert into T values ('12abc345');
1 row created.
SQL> insert into T values ('abc12345');
1 row created.
SQL> insert into T values ('123abc');
1 row created.
SQL> commit;
Commit complete.
SQL> select regexp_replace(Text, '[0-9]','') from T;
REGEXP_REPLACE(TEXT,'[0-9]','')
abc
abc
abc
IN OBIEE front end - Suppose in the column formual of column - Prod_desc - You have to use evaluate function - like this -
EVALUATE ('REGEXP_REPLACE(%1,%2,%3)',"PRODUCTS"."PROD_DESC",'[0-9]','') -
How to extract Idocs Numbers from Bulk Purchase orders
Hi Gurus,
I have around 1400 purchase orders.I need to get their Idoc numbers to reprocess in order to generate Sales orders.Is their any process to extract the Idoc numbers of all the purchase orders at a time. Pls suggest on the same.
Thanks in Advance
Ganesh KumarUse t.code WE02.
Enter IDOC basic type and date ranges. This will pull the IDOC numbers.
Regards -
Extracting the xml from string and parse it
Hi all,
I have a webservice, and calling one of the methods, returns xml data but store this data in a string.
For example:
String str = keysstub.getUserLMLArray(UserID,hash, Provider, Filter.ALL,TimeStampString).getXmlResults();returns <id>123456</id><id>123457</id><id>123458</id><id>123459</id><id>123461</id>and stores it in str.
I have to take read this xml from the string and parse it accordingly to retreive the data from it.
Please suggest how i can parse this xml from the string. it will be of great help. Code snippets from anyone would be of great help
Thanks and Regards,
Shikha* Get DOM document from a string containing valid XML.
* @param string String to read XML content from.
* @param varargs Optional arguments: 1: Validating?, 2: NamespaceAware?
* @return DOM document or null if failed.
* @throws Exception if failed.
static public Document toDocument(String string, boolean... varargs) throws Exception {
Document result = null;
if (string != null) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
if (varargs != null && varargs.length > 0) {
int count = varargs.length;
if (count > 0) {
factory.setValidating(varargs[0]); //needs error handler
if (count > 1) {
factory.setNamespaceAware(varargs[1]);
DocumentBuilder db = factory.newDocumentBuilder();
result = db.parse(new InputSource(new StringReader(string)));
}//else: input unavailable
return result;
}//toDocument()and don't forget that the string must be valid xml, so in your example the header is missing and the first element must embrace all subsequent elements, e.g.
<?xml version="1.0"?>
<ids>
<id>123456</id><id>123457</id><id>123458</id><id>123459</id><id>123461</id>
</ids> -
Parsing multiple digit numbers from string
I have a string, specifically "Cups = 30" that I need to parse out "30" from. How can I do this? I've gone through tokenizing, it's dirivng me crazy!!
This program will help you
import java.util.*;
class s21
public static void main(String args[])
try
String s1="Cups=30";
StringTokenizer st=new StringTokenizer(s1,"=");
while(st.hasMoreTokens())
st.nextToken();
System.out.println(st.nextToken());//This statement will
give 30 as output
catch(Exception e)
System.out.println(e);
Maybe you are looking for
-
What are the HDD specs i need to replace my HDD on a 2009 MBP?
Hi, My MBP was auto rendering video on FCP and I accidently closed the screen. When i reopened the screen it finished up rendering but FCP was completely frozen and i couldnt quit or open the force quit menu so i did a manual restart. When the comp
-
Data-sources.xml instead of bc4j.xcfg
Please give me some direction on how I can configure my Application Module to use JNDI lookup of my data-sources.xml file instead of using the bc4j.xcfg file. I know there is a way but I need a step by step process to get this done through configurat
-
VPN ASA inside Interface and ip pool are one same Subnet
Hi Everyone, I have configured RA VPN full tunnel. Inside interface of ASA is Vlan1 inside 10.0.0.1 255.255.255.0 CONFIG ip local pool 10-pool 10.0.0.51-10.0.0.100 mask 255.255.255.0 Need to know is it good
-
I am unable to authorize my itunes account on my new MacBook.
It keeps showing 'unknown error -42408'. I have two Apple IDs and it shows the same error message for both. It could well be related to the fact I removed itunes 11 from the new laptop and reinstalled itunes 10 because it is significantly better (bu
-
Call procedure without specifcation from shell scrip
I am writing shell script. In that I am calling one of the procedure lets say "ABC" from package "V". exec V.abc (); problem is that procedure ABC does not have specifications in package. It has only body defined. I am getting error as procedure unde