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);
Similar Messages
-
Cannot display more than 16 significant digit numbers from Oracle
The WebI Report cannot display more than 16 significant digit numbers from an Oracle data type field.
This occurs for both an ODBC and native driver connection to Oracle.
The data is defined by Number Data Type in Oracle, and view correctly in Universe, but display incorrectly in WebI report which created by InfoView.
I know BOE XIR2 has this behavior, but it seems that XI3.0 and XI3.1 also have this problem.
If this behavior in XI3.0 and XI3.1 perform by design? or it's a bug? and Why?
Thanks!Hi Sarah,
Precision limitation of a Web Intelligence filter constant :
In an Oracle database, a Number field type can store up to 38 digits. When creating a Web Intelligence report in the Java Panel, a condition is specified for this field (that is represented in the universe as a number), and a constant number is entered for its value, only up to 15 digits of precision are retained.
For example, if 1234567890123456789 is entered, the value becomes 1234567890123460000.
Or, if you have a column in database which has a number like 123.123456789012345678 it will display only 123.123456789012.
Cause
The reason for this limitation is that Java Panel represents a number internally as a Double field type with only 15 digits precision. This is by design.
Resolution
The only workaround is to change the field type to a Character field; however, doing so means losing the ability to perform calculations and/or sorting on the field.
This issue has been raised as an Enhancement Request and given Track ID # ADAPT00908702.
Regards,
Deepti Bajpai -
How can you generate Multiple random numbers from 1 to 49?
I am very new at programming with the iPhone SDK and I need some help with a project I am working on. What I want to do is set up a window with 6 labels and 1 button. When the user clicks the button, the program will populate 6 randomized numbers each ranging from 1 to 49, and then place each of 6 numbers in a label. But each time the program ends and starts again the numbers cannot be the same, and also when the user clicks the button, no label can have the same number twice, so for example. If label 1 had the number 10, the other 5 labels cannot have that number until the button is clicked again. I know how to set up the interface, I just need the code. I would so greatly appreciate someone's help in this matter. I have been trying to do this for days and I cannot figure it out. Possibly someone who knows tons about Objective C programming can help me!
Thank-you so very much!!I see that you're writing a lottery number generator. Perhaps the easiest way to do it is to emulate a real lottery: fill an array (NSMutableArray, probably) with the numbers between 1 and 49, pick one at random, remove that number from the array, and repeat. (You can think of the numbers as being the balls and the array as being the machine that pops them out.)
One simple way to get the random indices needed is to extract six random bytes from Randomization Services using SecRandomCopyBytes, then loop over them, using the modulo operator (%) to select an index within the size of the array.
And no, I'm not going to write your code for you. If I was going to do that, I could package and sell the app myself. -
How to parse multiple xml documents from single buffer
Hello,
I am trying to use jaxb 2.0 to parse a buffer which contains multiple xml documents. However, it seems that it is meant to only parse a single document at a time and throws an exception when it gets to the 2nd document.
Is there a way I can tell jaxb to only parse the first complete document and not fetch the next one out of the buffer? Or what is the most efficient way to separate the buffer into two documents without parsing it manually. If I have to search the buffer for the next document root and then split the buffer, it seems like that defeats the purpose of using jaxb as the parser.
I am using the Unmarshaller.unmarshall method and the exception I am getting is:
org.xml.sax.SAXParseException: Illegal character at end of document, <.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:476)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:198)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:167)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:184)
Thank you for your helpIt's just like any other XML parser, it's only designed to parse one XML document. If you have something that concatenates two XML documents together (that's what your "buffer" sounds like), then stop doing that.
-
Problem with multiple client numbers from a view
Hi Gurus,
I have a problem with a view
Creates a view with a UNION ALL stmt
=====================================
Create view vw_benifits
as
SELECT
Client_num, -- can have multiple values like 200,201,250
PERNR,
OBJPS,
ENDDA,
BEGDA,
AEDTM,
UNAME,
COB_MNTH_AMT
FROM
STG_SAP_PA9211_TB
UNION ALL
SELECT
null, -- no client number for legacy data
PERNR,
OBJPS,
ENDDA,
BEGDA,
AEDTM,
UNAME,
COB_MNTH_AMT
from
LEG_STG_SAP_PA9211_TB;
==============================
The second table contains legacy data (LEG_STG_SAP_PA9211_TB). The first table now contains multiple client data (ie the client_num can be 201,202,250 like that.
Now if the users qery the view they will only get that clients data.
eg selet * from vw_benifits where client_num=250 results only client 250 data. But I want to add the legacy data also with that.
I don't want to propose
selet * from vw_benifits where client_num in (250,NULL) since the users will be confused.
Is there any other way to do this . my requirement is like
If they query
select * from vw_benifits where client_num=250, the data should include all the records satisfying client=250 + the records from the legacy data. The view need to be created like that.
Appreciate your help
DeepakHi Thanks for the suggestion.
But I am not sure this may work for me. Here my users may not be able to use that since they don't know Oracle.
I want to hide that details from them
They may just issue a statement like this
select * from vw_benifits where client_num =250
Or
select * from vw_benifits where client_num =400 . But both times I need to show them the data from the legacy table.
Deepak -
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
kumarHi ,
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 -
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]','') -
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 -
Parsing ANSI color codes from strings
Hello,
I'm putting together a telnet app/applet and the next big milestone
on my list is putting in ANSI color support (or at least automatically
removing it). However, I've been having trouble figuring out a way to
read the codes.
For anyone that doesn't know, this is an example of an ANSI code: \033
[30m where "30" can be a number from 0 to 49.
I've tried using a regexp to find the codes, but with my limited regexp
knowledge, nothing has seemed to work so far. Can anyone help me out
with this?
Thanks.String test = "one\033[40mtwo\033[38mbloggle";
System.out.println( test.replaceAll( "\\033\\[\\d\\dm", "[test]" ) );? -
in my C# project I have an array type of String. the array gets numbers from type int.
int numCell;
string[] arr = new string[numCell];
then i use it in a function like this:
sum += int.Parse(arr[i]);
and it works!
but, when i dothe same thing in WPF it tells me:
Input string was not in a correct format.
what shouuld i do?Why did you mark your own question as answer? Please unmark it.
>>if in C# it worked why wouldn't it work in wpf?
As I have already mentioned, it is because of the actual value of arr[i]. It has nothing to do with Windows Forms or WPF but it is possible that your WPF application has put a different value in the array than your Windows Forms Application did. And if this
specific value is not a valid number the parsing will always fail. So you should check the values that put into the array and probably use the int.TryParse method to do the parsing:
int sum;
if (!int.TryParse(arr[i], out sum))
//the value of arr[i] was NOT a valid number...
This will however not change the fact that for example the value "D1" cannot be converted to an int using the int.Parse or int.TryParse method.
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question. -
Extract numbers from mixed string.
How do I extract numbers from a mixed-character string?
These are house numbers and I have some exceptions - examples below.
How do I get rid of the letter/dash part, and keep the numeric part only?
38A
5600B
23-A
Thanks a lot.
-JohnIt does not work if you have a string like 3343S##@1~!234
OP, you can try this:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> with t as(
2 select '38A' c1 from dual union all
3 select '5600B' from dual union all
4 select '5Bas@#$%1SDf3ff`~7' from dual union all
5 select '3343S##@1~!234' from dual union all
6 select '23-A+9' from dual )
7 --
8 select c1,regexp_replace(c1,'[^[:digit:]]') only_num from t;
C1 ONLY_NUM
38A 38
5600B 5600
5Bas@#$%1SDf3ff`~7 5137
3343S##@1~!234 33431234
23-A+9 239
SQL> -
I have registered a credit card for purchasing apps from the app store. My bank has issued a new chip based card and now the 16 digit numbers have changed. How do I register the new card for flowless purchases?
Go to Apple Menu > App Store > View my account > sign in and then edit the payment details with the new card details.
I am assuming that your card and supporting bank are in the same country as your residential (billing) address and that you are using the App Store of that country. -
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> -
More efficient way to extract number from string
Hello guys,
I am using this Regexp to extract numbers from a string, and I doubt that there is a more efficient way to get this done:
SELECT regexp_replace (regexp_replace ( REGEXp_REPLACE (' !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 | " ' , '[[:punct:]]',''), '[[:space:]]',''), '[[:alpha:]]','') FROM dual
{code}
Is there a more efficient way to get this done ?
Regards,
FatehOr, with less writing, using Perl syntax \D (non-digit):
SELECT regexp_replace(' !@#$%^&*()_+= '' + 00 SDFKA 324 000 8702 234 | " ','\D')
FROM dual
REGEXP_REPLACE(
003240008702234
SQL>
{code}
SY. -
How do I convert from String to float?
Hi,
you can use a Double for example - assuming value is that string to parse
float f;
try { Double d = new Double(value); f = d.floatValue(); }
catch (NumberFormatException e) { f = 0.0; } // error - string value could not be parsed
// here use your float fHope, that helps
greetings Marsian
P.S.: the Double class is usefull for that, because you also can get intValue(), doubleValue() or longValue() out of it for example. The StreamTokenizer for example parses numbers also only to double.
Maybe you are looking for
-
How to send mail with pdf attachment.
hello, I want to know if I can send a pdf attachment via mail. My PDF file is somewhere in the server and its content doesn't need to be changed by the program. the program just needs to find the pdf in server, then it will just send pdf file as atta
-
How do use my itunes library in another computer
I have an itunes account and a library on my pc at work, but when i try to accede to my library on itunes on my personal computer it doesn´t work. What should I do? on both pc's I have windows xp. Best regards Elisabete Gomes
-
Essbase Error: Error executing formula
Problem Description: When running query in BI Answer, error message is shown as the following: State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. Essbase Error: Error executing formula for [MIX %]:
-
How to use MDX with Maxl?
I have been looking at documentation on the MDX language and would like to program some simple queries using it. I tried to run it inside a command line MAXL call and couldn't figure out how to tell it the output format. Are there manuals that cover
-
Issue BAPI_PO_CREATE1
Hi, I am creating Purchase order using the BAPI , BAPI_PO_CREATE1, but the problem is that, when I am passing new Net_price in ITEM and 'X' in ITEMX for the same, the Po is created but the price I passed is not there it is adopted from OLD. What Pa