How to split a string
I have a string that is I get when running. its length is variable. Suppose that its "NUMBER = ABC1004457844 | "It's the number you wanted." I want to get the string between '=' and ' | '. It can be variable, as I get it when the server running. This trend is the same in each response from the server.
Please help someone. Its urgency.
Hi you can use the indexof and substring in this case methods indexof method takes on the character and returns the index of the provided character, now give your characters required to indexof() alternately and get these indexes, now use the substring (startingIndex, endingIndex) for your required string.
Tags: BlackBerry Developers
Similar Questions
-
How to split a string into several substrings parent using a delimiter
Hello
I am forced to split a string into several substrings parent using a delimiter.
And insert these substrings in variuou of the columns of a table in a row.
For example. The sting is: ABC * DEF * GHI * JKH *.
where ' *' is the separator.
Desired output:
Col1 Col2 Col3 Col4 Col5
------- -------- -------- ------- ---------
JKH GHI ABC DEF (null)
Could you please guide me how can I achieve this.
Thank you
Bogoss
Hello Salim,
Leave the thread for reference... got this excerpt:
with t as
(
Select "c: its: hgfd:1:23" Str
)
Select
REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 1, null, 1) col1
, REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 2, null, 1) col2
, REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 3, null, 1) col3
, REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 4, null, 1) col4
, REGEXP_SUBSTR (str, ' ([^:] *)(:|$)', 1, 5, null, 1) col5
t;
This code snippet works well, but for the fixed columns. Here are 5 predefined columns.
But I need to have a logic that I can browse the string any No.. sometimes.
For example. If I get 3 secondary channels of the parent chain... I need to insert into 3 columns.
And if I get 6 strings under... I need to insert into 6 columns.
Could you please help me develop a logic like that.
I use Oracle database 10g.
And the data are currently being collected on external table... but I can store in a variable or a column of a database table.
Thank you
Bogoss
-
How to split a string into columns
Hi all
Have a strings like this, where the delimiter is
Thanks in advance10:00 | x1 | 2 | RO | P | Con ausilio | y1 10:10 | x2 | 1 | RO | | | y2 10:20 |x3 | 3 | | | | y3 10:30 |x4 | 3 | RO | N | Con aiuto | y4 10:40 |x5 | 1 | RO | | | y5 how can I break it up into columns, for example, the first char(before first pipe) insert in first variable, then, after first pipe, second characters in a other column ans so on col1 := '10:00'; col2 := 'x1'; col3 := '2'; col4:= 'RO'; col5 := 'P'; col6 := ' Con ausilio '; col7 := 'y1'; col1 := '10:10'; col2 := 'x2'; .. and so on
Hello
If you want to split the string str into 7 columns :
SELECT TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 1)) AS col1 , TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 2)) AS col2 , TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 3)) AS col3 ... , TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 7)) AS col7 FROM table_x ;
If you want to split it inot 7 variables :
col1 := TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 1)); col2 := TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 2)); col3 := TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 3)); ... col7 := TRIM (BOTH FROM REGEXP_SUBSTR (str, '[^|]+', 1, 7));
-
How to split the string?
Hello
I get data like ~^1820|-93.13|+4.57|-3.20 | 183,62'
any value assigned something like height, angle, etc...
I want to divide this string could someone please help me how to do this.
I would like in a similar. 1820
a = 93.13
b = + 4.57
c =-3.20
d = 183.62
Thank you much in advance.
With the best wishes,
Ankit.
Hi Pierre,.
use SpreadsheetStringToArray:
-
How to split a string variable in BPEL
Hello
I have a variable which I fetch it database with a delimiter. Need to separate this variable to obtain all the values in the BPEL.
For example, I get a column that contains data from a, b, c end,
I need all these values separately in the BPEL process as 'a' 'b' 'c' and 'end '.
In java, we can do this by using the below lines...
= String values "a, b, c, end;
String [] array array1 = values.split(",");
I don't find a split function in BPEL string functions. Could someone show some light on this please.
Kind regards
PSNo, there is not such a generation - in function for this. You could do:
-Create a Java class to do this. Wrap the Java class as a Web service, deploy it and call it from BPEL.
-Create a PL/SQL function to do this. Access the function from PL/SQL to the DB adapter.Marc
http://orasoa.blogspot.com -
How to divide the string in bb-cascades
I have a table of data as json
{"RegistrationResult":"Registered Success:Empid:157:TableName:COMPANY156"}
Now, how I want to split the show list view in qml and string as the follwing
Success stories
EmpID = 157
TableName = COMPANY156
Please tell the concept of cutting a string and show the result in qml
I can get the result of the follwing method:
{"RegistrationResult":["Registered Success","Empid":"157","TableName":"COMPANY156"]}
But I do not know how to split the string for a first... Help, please...
svmrajesh wrote:
,......
"Registered Success:Empid:157:TableName:COMPANY156"}
Take a look at QString docu
Just do something like
myString.split(':')
and you get a QStringList and this QStringList is directly mapped to a table in QML JavaScript
-
I implemented the Oracle text search in my database. Now I have this query
Select ctx_thes.syn ('RED', 'MY_THESAURUS') of double;
the output is displayed as
{RED} | {MIXTURE OF RED} | {TABLE RED} | {RED}
and I want to get the words in separate lines, i.e.
Red
Mixture of Red
Red table
Red wine
How to split the string into lines?
SELECT * FROM ( SELECT DISTINCT REGEXP_SUBSTR ('{RED}|{RED BLEND}|{RED TABLE}|{RED WINE}', '({)([A-Z]+ *[A-Z]*)(})', 1, LEVEL, 'i', 2) val FROM DUAL CONNECT BY LEVEL <= REGEXP_COUNT ( '{RED}|{RED BLEND}|{RED TABLE}|{RED WINE}', '|') + 1) WHERE val IS NOT NULL;
-
split a string into pl/sql
Hello
How to split a string and store in an associative array in pl/sql.function
My string like this
'1102,1101,1012,1011,1010,1009,1008,1007,1006,10005,1004,1003,1002,1001'
and assign it to the array list. According to
can someone please help
concerning
rYou can try the following. Although I recommend, it would be better to write the function code php as a java stored procedure parser and use the result. We have a class defined in Java String Tokenizer.
-- Define function to split string into tokens FUNCTION get_token( p_input_string IN VARCHAR2, -- input string p_token_number IN PLS_INTEGER, -- token number p_delimiter IN VARCHAR2 DEFAULT ',' -- separator character ) RETURN VARCHAR2 IS v_temp_string VARCHAR2(32767) := p_delimiter || p_input_string ; v_pos1 PLS_INTEGER ; v_pos2 PLS_INTEGER ; BEGIN v_pos1 := INSTR( v_temp_string, p_delimiter, 1, p_token_number ) ; IF v_pos1 > 0 THEN v_pos2 := INSTR( v_temp_string, p_delimiter, 1, p_token_number + 1) ; IF v_pos2 = 0 THEN v_pos2 := LENGTH( v_temp_string ) + 1 ; END IF ; RETURN( SUBSTR( v_temp_string, v_pos1+1, v_pos2 - v_pos1-1 ) ) ; ELSE RETURN NULL ; END IF ; EXCEPTION WHEN OTHERS THEN RAISE; END get_token; -- Call the above function in loop for a string with N tokens DECLARE TYPE assoc_arr_str_typ IS TABLE OF VARCHAR2(100) INDEX BY PLS_INTEGER; str_arr assoc_arr_str_typ; v_str VARCHAR2(200) := '1102,1101,1012,1011,1010,1009,1008,1007,1006,10005,1004,1003,1002,1001' ; v_token VARCHAR2(4) ; i PLS_INTEGER := 1 ; BEGIN LOOP v_token := get_token( v_str, i , ',') ; EXIT WHEN v_token IS NULL ; dbms_output.put_line( v_token ) ; str_arr(i) := v_token; i := i + 1 ; END LOOP ; END ; /
Published by: GG 24 March 2011 09:51
-
Simple question: how to divide the string into multiple lines concatenated?
Hi people,
Maybe it's an easy question.
How to split a string that is concatenated into multiple lines by using the SQL query?
ENTRY:
Delimiter = ', '.select 'AAA,BBB,CC,DDDD' as data from dual
Expected results:
I'm looking for something nice to feature "an opposite to «sys_connect_by_path»»data ------------ AAA BBB CCC DDDD
Thank you
Tomaswith t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' as txt from dual) -- end of sample data select REGEXP_SUBSTR (txt, '[^,]+', 1, level) from t connect by level <= length(regexp_replace(txt,'[^,]*'))+1 REGEXP_SUBSTR(TXT,'[^,]+',1,LE ------------------------------ aaaa bbbb cccc dddd eeee ffff
-
Hello
I'm using action made by Christophe (http://www.vcoteam.info/learn-vco/code-snippets-cancel-one-of-your-running-workflows.html) in order to cancel some workflows.
Since the selection for tokens window does not display the parameters of the token, I created another entry for my workflow that is supposed to contain the name of the virtual machine, only for infomational purposes.
I created an action to do this. When I use just "return myWorkflowToken.getInputParameters ();" then all settings are written to the input box.
In my case, it looks like this:
{ram = 3000.0, date = Mon Jan 24 16:25:16 THIS 2011, vm = < @id = FinderResult' VC:VirtualMachine/si0vm271/vm - 852' @name = "si0vm562" >, UC = 3.0}
Since I need only the name of the virtual machine, in this case the part after @name (si0vm562), I need to retrieve it somehow off the chain.
In the Orchestrator API, I found the String class with the method 'split '.
At first, I tried to split the string into two parts using this code:
var params_s = myWorkflowToken.getInputParameters ();
var params_a_s = params_s.split ("name");
return params_a_s [1];But when I run the workflow, the input dialogue tells me that the "split" function cannot be found.
How can I retrieve the VM name on the report of a running workflow?
Thank you
Concerning
Andreas
Hi Andreas,
I don't think that splitting strings works for your case.
In fact workflowToken.getInputParameters () does not return a string. It is ch.dunes.scripting.jsmodel.JSProperties instead (you can check this of the Orchestrator client tools-> API Explorer). The split function is not found on the params_s variable.
In order to achieve your goal, you can try the following:
get the vm parameter
Use the parameter name. This is the vm used according to the result of your message
VM var = workflowToken.getInputParameters () .get ("vm");
You can check for safety if the virtual machine is defined, except that the virtual machine is the required parameter
If (vm! = null) {}
return vm.name
}
The code snippet above you should return the value set for the parameter of the virtual machine.
Hope this helps,
Martin Marinov
-
Oracle regular expressions - splits the string into words for
Hello
Nice day!
My requirement is to split the string into words.
So I need to identify the new line character and the semicolon (;), comma and space like terminator for string entry.
Please note that I am currently embedded blank and the comma as separator, as shown below.
Select regexp_substr('test)
TO
string in words, "([^, [: blanc:]] +) (', 1, 1) double;"How to integrate the semicolons and line break characters in regular expression Oracle?
Please notify.
Thanks and greetings
Sree
This has nothing to do with REGEXP. Is SQL * more parser does not not a semicolon at the end of the line:
SQL > select ' testto, mm\;
ERROR:
ORA-01756: city not properly finished chainSQL >
Just break the chain:
SQL > select regexp_substr ('testto, mm\;' |) '
2 string into words
3 \w+',1,level ',') of double
4. connect by level<= regexp_count('testto,mm\;'="" ||="">=>
5 string in words
6 ','\w+')
7.REGEXP_SUBSTR ('TESTTO, MM\;' |') STRINGIN
--------------------------------------
Testto
mm
string
in
WordsSQL >
Or modify SQL * more the character of endpoints:
SQL > set sqlterm.
SQL > select regexp_substr ('testto, mm\;)
2 string into words
3 \w+',1,level ',') of double
4. connect by level<=>=>
5 string in words
6 ','\w+')
7.REGEXP_SUBSTR ('TESTTO, MM\;) STRINGINTOWO
--------------------------------------
Testto
mm
string
in
WordsSQL >
SY.
-
splits the string into 3 parts
Hello
I have a requirement to split the string into 3 different room example inf.ethz.ch should be subdivided into inf ethz ch in 3 different column
We have table called email within this column contains all identification of email we need to divide email with dot (.) in different columns and display please suggest how to implement in the query
Thank you
Sudhir
Use REGEXP_SUBSTR:
SQL > with t as (select ' inf.ethz.ch' double txt)
2 Select regexp_substr (txt,'[^.] +') part_1,.
3 regexp_substr (txt,'[^.] +', 1, 2) part_2,.
4 regexp_substr (txt,'[^.] +' 1, 3) part_3
5 t
6.BY PARTY PA
--- ---- --
INF ethz chSQL >
Or you can use SUBSTR + Instr.
SY.
-
Split a string when a url is found
Hello
I am trying to find a URL within a string and it (the text before the link itself and the following text) divided into distinct parts. I tried the split (...) method, but never adds the URL as one of the parts of the split. Is it possible to do? That's what I'm currently using:
I can't understand how to split like that, but I tried this, which works, just not as I want (showing the first part, end of game and the link):public static List<String> findUrls(String input) { List<String> result = new ArrayList<String>(); Pattern pattern = Pattern.compile("\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"); Matcher matcher = pattern.matcher(input); while (matcher.find()) { result.add(matcher.group()); } return result; }
public void findUrl(String input) { String[] test = input.split("\\(?\\b(http://|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]"); for (int i = 0; i < test.length; i++) { System.out.println(test);
}
}
System.out.println (Regex.findUrl ("just testing http://www.google.com/ this split of the string"));The output I get when doing the findUrl(...) method is:
just testis
This string of splitAny suggestions or help? Thanks, aeternaly
It's ugly, and I know there's a way easier and cleaner to do and I don't know if that's what you want, but you may be able to use it as a starting point:
"xxx abc xxx def xxx xxx ghi jkl xxx".split("((?<=xxx)\\s++)|(\\s++(?=xxx))") // gives ["xxx", "abc", "xxx", "def", "xxx", "xxx", "ghi jkl", "xxx"]
where xxx is your URL scheme. You can keep the spaces around your matches to that model you rid of occurrences of {noformat} \\s++ {noformat}, but this also includes the empty string at the beginning of the sequence and the spaces between the consecutive games:
["", "xxx", " abc ", "xxx", " def ", "xxx", " ", "xxx", " ghi jkl ", "xxx"]
Also, I think that your URL scheme is too complex. Why not use something much more simple that will work in the majority of cases?
pat = "(http://|www\\.)\\S++" input = "http://www.google.com/a/b?c=d&e=f abc www.bibblebobble.net def ghi www.bibblebobble.net http://honkhonk"; input.split(String.format("((?<=%s)\\s++)|(\\s++(?=%s))", pat, pat)) Result: ["http://www.google.com/a/b?c=d&e=f", "abc", "www.bibblebobble.net", "def ghi", "www.bibblebobble.net", "http://honkhonk"]
Although I suspect that's what you were trying to do, but maybe you didn't know that you could use
\S
means "anything but a space" and
+
to mean "one or more".
http://download.Oracle.com/javase/tutorial/essential/regex/
http://www.regular-expressions.info/tutorial.htmlEDIT: I probably account for the https protocol and ignore case. Must be something like that, but I have not tested:
pat = "(?i)(http(s?)://|www\\.)\\S++"
Edited by: jverd August 6, 2011 14:09
-
Concatenate and split the string
Hi all
Is there some how we can split the string like this "1 | ~ | Diego | Maradona | ~ | Footballer | The Argentina.
in the table of 3 elements: '1', ' Diego | Maradona', ' football '. The Argentina.
Here is my code
and put it is:public static void main(String args[]){ System.out.println("========USE SPLIT========== " ); String data = "1 |~| Diego|Maradona |~| Footballer|Argentina"; String[] items = data.split(" |~| "); for (String item : items) { System.out.println("item = " + item); } StringTokenizer tok = new StringTokenizer(data," |~| "); System.out.println("========USE TOKENIZER========== " ); while(tok.hasMoreElements()){ System.out.println("item = " + tok.nextToken()); } }
= USE SPLIT =.
Item = 1
Item = |
Item = |
Item = Diego | Maradona
Item = |
Item = |
Item = football | Argentina
= USE TOKENIZE =.
Item = 1
Item = Diego
Item = Maradona
Item = footballer
Item = Argentina
Published by: mycoffee on February 1, 2011 06:49Split() takes a regular expression. ' | ' has a special meaning in regular expressions.
Try to use
" \\|~\\| "
as the argument of split()
-
How to convert a string of text input field data I already.
I have a string search API of Twitter for keywords, for example:
var url:String = "http://search.twitter.com/search.json?q=Robin%20&lang=en&rpp=100";
I also have a dynamically created textfield input:
var inputField:TextField = new TextField(); addChild(inputField); inputField.border = true; inputField.width = 200; inputField.height = 150; inputField.x = 75; inputField.y = 50; inputField.type = "input"; inputField.multiline = true; inputField.restrict = "A-Za-z0-9"; stage.focus = inputField;
But how to take data from the text input field and append it to the string, be sure the input data must go to the part of the string keyword. In this example, the keyword is "Robin".
It should be implemented as shown below...
URL = url.replace (regexp, '? ") q = "" + yourTextField.text + "&"); "
There are other ways to do this methods involving chains, where you can first split the string on the '? q =", and then divide the second element of this result on the '&', then replace the first element of this second split with your text textfield and then sew the pieces back together as a single string.
Maybe you are looking for
-
In the past, I've always been able to search a specific e-mail from a client in the search bar up in Thunderbird, and most of my emails now not appear to customers more. They are there, but I have to physically to scroll through all my emails and fin
-
message saying that my ID was changed to apple
I get messages from Apple (?) said that my ID was changed to apple. I have not changed it and can still access my account with my existing connection information, so should I worry?
-
Z220: The CPU utilization high idling: how to troubleshoot?
My new Z220 with i5-3470 CPU, 16 GB RAM, Win 7 Pro 64-bit, shows a very high utilization of the processor idling: 35 to 39%, on average. I looked at the Win 7 performance monitor and there it shows system interrupts, in slow motion, a lot of 20-25% t
-
When I use Excel Table.vi easy to export my data, the double numeric values are to be less accurate. For example, 0,0054 at 0.005 and 0,0085 to 0.009. Is anyway to stop this accident?
-
Does not connect to my wireless network
I have compaq Presario F700 Series Notebook Pc running on Windows Vista when I try to connect to my wireless router, it says unidentified network and custom give me internet acess Ive changed the Ipv6 and Ipv4 auto Ive restored the pc too factory set