Extracting string from another string
Hi,
I have a problem that I am having difficulty solving, if anyone has any bright ideas it would be a great help.
I have a description field in one of my tables and the description would read something like
my website can be found at www.mywebsite.com, and it is great
I want to be able to extract the web address from this sentance, so the result would be
www.mywebsite.com
I can do this specific for one sentance but I can't find a way to do it for many different sentances.
cheers in advance
r u expecting this..?
select substr('my web site is www.abcd.com and u can...',instr('my web site is www.abcd.com and u can...','www.',1),instr(substr('my web site is www.abcd.com and u can...',instr('my web site is www.abcd.com and u can...','www.',1)),' ',1)) from dual;
Similar Messages
-
Take and delete a String from another String
I have original input string= 111100001111
I need to Take for example the least 4 bits .... Output= 1111
and to be removed from the original input string so the original input string= 11110000
I am trying to make a generic one but the point is that I can not delete subset that I take from the original input String.
How can I take and delete from a string in the same time?
Solved!
Go to Solution.Something like this?
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Split String.png 13 KB -
Checking for an element in a string from another string
Hi Guru's,
I have 2 comma seperated strings. Say like this.
a VARCHAR2(100) := '1,2,3,4,5,6,7,8,9,10';
b VARCHAR2(100) := '2,6,9';
My requirement is like I want to check the string a, whether it has any of the element in b. I am trying to use the regular expression. But I was not able to do it.
Kindly help me.
Regards,
VJSQL> var cur refcursor
SQL> declare
a varchar2 (100) := '1,2,3,4,5,6,7,8,9,10';
b varchar2 (100) := '2,6,9';
begin
open :cur for 'select column_value common
from table (sys.dbms_debug_vc2coll (' || a || ') multiset intersect sys.dbms_debug_vc2coll (' || b || '))';
end;
PL/SQL procedure successfully completed.
SQL> print
COMMON
2
6
9
3 rows selected. -
Call String from another method
hey,
Im pretty new to java and Im having problems with calling a String from another method
I have two public voids, in one of them I have a String which I wanna use in another method.
Thankshere is some of my code:
public void getOrder() {
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File("c:/orders.xml"));
// normalize text representation
doc.getDocumentElement().normalize();
System.out.println("Root element of the doc is " + doc.getDocumentElement().getNodeName());
// lees orders
NodeList orderlijst = doc.getElementsByTagName("order_naam");
System.out.println("totale aantal orders : " + orderlijst.getLength());
// Element orderitem = (Element) orderlijst.item(0);
System.out.println("name=" + doc.getElementsByTagName("order_naam").item(0).getFirstChild().getNodeValue());
String st =doc.getElementsByTagName("order_naam").item(0).getFirstChild().getNodeValue();
public void createGUI () {
this.removeAll();
lbltest = new JLabel();
lbltest.setBounds(20, 40, 150, 20);
lbltest.setFont(new Font("Verdana", Font.BOLD, 12));
this.add(lbltest);
i want to use the String st in the jLabel in createGUI -
To read string from another file
Dear friends
I am working on a project where i need to read log files which are there on my C drive.
I got a folder and from that i need to read string from another folder and name them as URL,TS etc..so any body have any idea about this...I have no idea what you're even trying to do. Can you try explaining your problem more clearly and in more detail?
-
Replace a string with another string in a file
I have to replace a string with another string. Say for example in a html file it got a line like,
<a href="##"></a>
now i want to replace this ## with the full derived path like
"c;\\sample folder\\sample subfolder\\samplefile.html"
can someone help me to do this?
pls tell me from the file opening till closing the file.I have to replace a string with another string. Say
for example in a html file it got a line like,
<a href="##"></a>
now i want to replace this ## with the full derived
path like
"c;\\sample folder\\samplesubfolder\\samplefile.html"
can someone help me to do this?
pls tell me from the file opening till closing the
file.
public class Buckel {
final static String CONST = "c:\\sample folder\\samplesubfolder\\samplefile.html";
public Buckel() {
public static void main ( String[] argv ) throws Exception {
int idx = 0;
String in = "<a href=\"##\"></a>", // We'll imagine this just gets here somehow. If it's on the i/p file then take the '\' out B4 and aft the '##'.
out = "";
idx = in.indexOf( "##" );
if ( idx > 0 ) {
out = in.substring( 0, idx ) + CONST + in.substring( idx+=2, in.length() );
System.out.println( out );
} -
Replacing a special character in a string with another string
Hi
I need to replace a special character in a string with another string.
Say there is a string - "abc's def's are alphabets"
and i need to replace all the ' (apostrophe) with &apos& ..which should look like as below
"abc&apos&s def&apos&s are alphabets" .
Kindly let me know how this requirement can be met.
Regards
SukumariREPLACE
Syntax Forms
Pattern-based replacement
1. REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF]
pattern
IN [section_of] dobj WITH new
[IN {BYTE|CHARACTER} MODE]
[{RESPECTING|IGNORING} CASE]
[REPLACEMENT COUNT rcnt]
{ {[REPLACEMENT OFFSET roff]
[REPLACEMENT LENGTH rlen]}
| [RESULTS result_tab|result_wa] }.
Position-based replacement
2. REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
[IN {BYTE|CHARACTER} MODE].
Effect
This statement replaces characters or bytes of the variable dobj by characters or bytes of the data object new. Here, position-based and pattern-based replacement are possible.
When the replacement is executed, an interim result without a length limit is implicitly generated and the interim result is transferred to the data object dobj. If the length of the interim result is longer than the length of dobj, the data is cut off on the right in the case of data objects of fixed length. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or hexadecimal zeroes. Data objects of variable length are adjusted. If data is cut off to the right when the interim result is assigned, sy-subrc is set to 2.
In the case of character string processing, the closing spaces are taken into account for data objects dobj of fixed length; they are not taken into account in the case of new.
System fields
sy-subrc Meaning
0 The specified section or subsequence was replaced by the content of new and the result is available in full in dobj.
2 The specified section or subsequence was replaced in dobj by the contents of new and the result of the replacement was cut off to the right.
4 The subsequence in sub_string was not found in dobj in the pattern-based search.
8 The data objects sub_string and new contain double-byte characters that cannot be interpreted.
Note
These forms of the statement REPLACE replace the following obsolete form:
REPLACE sub_string WITH
Syntax
REPLACE sub_string WITH new INTO dobj
[IN {BYTE|CHARACTER} MODE]
[LENGTH len].
Extras:
1. ... IN {BYTE|CHARACTER} MODE
2. ... LENGTH len
Effect
This statement searches through a byte string or character string dobj for the subsequence specified in sub_string and replaces the first byte or character string in dobj that matches sub_string with the contents of the data object new.
The memory areas of sub_string and new must not overlap, otherwise the result is undefined. If sub_string is an empty string, the point before the first character or byte of the search area is found and the content of new is inserted before the first character.
During character string processing, the closing blank is considered for data objects dobj, sub_string and new of type c, d, n or t.
System Fields
sy-subrc Meaning
0 The subsequence in sub_string was replaced in the target field dobj with the content of new.
4 The subsequence in sub_string could not be replaced in the target field dobj with the contents of new.
Note
This variant of the statement REPLACE will be replaced, beginning with Release 6.10, with a new variant.
Addition 1
... IN {BYTE|CHARACTER} MODE
Effect
The optional addition IN {BYTE|CHARACTER} MODE determines whether byte or character string processing will be executed. If the addition is not specified, character string processing is executed. Depending on the processing type, the data objects sub_string, new, and dobj must be byte or character type.
Addition 2
... LENGTH len
Effect
If the addition LENGTH is not specified, all the data objects involved are evaluated in their entire length. If the addition LENGTH is specified, only the first len bytes or characters of sub_string are used for the search. For len, a data object of the type i is expected.
If the length of the interim result is longer than the length of dobj, data objects of fixed length will be cut off to the right. If the length of the interim result is shorter than the length of dobj, data objects of fixed length are filled to the right with blanks or with hexadecimal 0. Data objects of variable length are adapted.
Example
After the replacements, text1 contains the complete content "I should know that you know", while text2 has the cut-off content "I should know that".
DATA: text1 TYPE string VALUE 'I know you know',
text2(18) TYPE c LENGTH 18 VALUE 'I know you know',
sub_string TYPE string VALUE 'know',
new TYPE string VALUE 'should know that'.
REPLACE sub_string WITH new INTO text1.
REPLACE sub_string WITH new INTO text2. -
I need to append a string to another string
I'm working with some inherited code, I'm a Colf Fusion
novice myself, and I'm trying to make this order form display the
correct data. The problem is a lot of data in the database is
missing. Description in the QStockDB query can contain a lot of
stuff. For our full color work the text "4/0", "4/BLACK", and "4/4"
are consistent so I'm changing the newitem (I know, not very
descriptive but it's not my code) to CMYK Printing.
<cfif #QStockDB.description# contains "4/0"><cfset
newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains
"4/4/BLACK"><cfset newitem = "CMYK Printing"></cfif>
<cfif #QStockDB.description# contains "4/4"><cfset
newitem = "CMYK Printing"></cfif>
I want to then go back through description and compare it
more to add more description. For instance with this:
<cfif #QStockDB.description# contains "12 pt"><cfset
newitem = newitem + " - BC"></cfif>
I know that the job is a business card. So I want to append
the newitem variable with " - BC". Likewise:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
displays CMYK Printing - Catalog Sheets. Or, it should... or,
more precisely, I want it to. :)
How do I append a string to another string?+ is the addiion operator and works with numbers. Because
your string is a ...well, string... you need to use an ampersand.
Thus, instead of:
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem + " - Catalog
Sheets"></cfif>
Use...
<cfif #QStockDB.description# contains
"catalog"><cfset newitem = newitem & " - Catalog
Sheets"></cfif>
<cfoutput>#newitem#</cfoutput>
At least I think that will work - haven't tested it
though. -
Hi,
I am curious if there is an easy way to extract an int value from a String.
For example, "Rb23" to get 23. The length of the part in front of the integer is variable.
Thanksthis seems to work:
public int extract(String s) {
String result = "";
char c[] = s.toCharArray();
int j = c.length-1;
if (!Character.isDigit(c[j])) {
return 0;
do {
result+=c[j--];
} while (j > 0 && Character.isDigit(c[j]));
return Integer.parseInt(new StringBuffer(result).reverse().toString());
}it will return 0 if no numbers are found at the end of the string -
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> -
Extracting the partial string from the string in oracle
Hello Friends,
I have a string like this
var str = '/G/CNH/CNHCornerstone/currentCode/data/Working/Images/ModelImages/png/7402203E-607D-E111-9CA5-005056875BD6.png'
I want to extract only 7402203E-607D-E111-9CA5-005056875BD6 from the string .
Please let me know how to implement this ..
thanks/kumar
Edited by: kumar73 on Apr 10, 2012 12:34 PMhope this works
set serveroutput on
declare
str1 varchar(4000);
str2 varchar(4000);
begin
str1 := '/G/CNH/CNHCornerstone/currentCode/data/Working/Images/ModelImages/png/7402203E-607D-E111-9CA5-005056875BD6.png';
dbms_output.put_line('string 1 : ' || str1);
str2 := substr(str1,71);
dbms_output.put_line('string 2 : '||str2);
end;
output
string 1 : /G/CNH/CNHCornerstone/currentCode/data/Working/Images/ModelImages/png/7402203E-607D-E111-9CA5-005056875BD6.png
string 2 : 7402203E-607D-E111-9CA5-005056875BD6.png
PL/SQL procedure successfully completed -
Extracting data from a string of characters
Hi,
I have a problem that I am having difficulty solving, if anyone has any bright ideas it would be a great help.
I have a description field in one of my tables and the description would read something like
my website can be found at www.mywebsite.com, and it is great
I want to be able to extract the web address from this sentance, so the result would be
www.mywebsite.com
I can do this specific for one sentance but I can't find a way to do it for many different sentances.
cheers in advanceIf you're using 10g, you probably want to do something with regular expressions:
SQL> with strings as (
2 select
3 'my website can be found at www.mywebsite.com, and it is great' str
4 from
5 dual
6 union all
7 select
8 'my website can be found at WWW.myWebSite.com, and it is great'
9 from
10 dual
11 union all
12 select
13 'our web address is www.mywebsite.co.uk' str
14 from
15 dual
16 union all
17 select
18 'http://www.mywebsite.com/great'
19 from
20 dual)
21 select
22 s.str
23 , regexp_substr(s.str, 'www\.[a-z0-9-\.?]*', 1, 1, 'i') extr
24 from
25 strings s
26 /
STR EXTR
my website can be found at www.mywebsite.com, and it is great www.mywebsite.com
my website can be found at WWW.myWebSite.com, and it is great WWW.myWebSite.com
our web address is www.mywebsite.co.uk www.mywebsite.co.uk
http://www.mywebsite.com/great www.mywebsite.comYou'd be better asking this kind of thing on the PL/SQL (and definitely better asking someone other than me anything further about regular expressions!) -
select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - ProductionI want to extract xyz_xyz,abc_abc words from the string ' select * from TEMP_TABLE where trunc(xyz_xyz) = ''xyz'' and trunc(abc_abc) = ''abc'') '
i have tried with this query...
select regexp_substr('select * from TEMP_TABLE where trunc(xyz_xyz) = ''xyz'' and trunc(abc_abc) = ''abc'')', 'trunc[^'''']+''') from dual
can some one help me on this?
Thanks,
MikeHi, Mike,
Mike wrote:
I apologize for this..
create table TEMP_TABLE ( col1 varchar2(10),col2 varchar2(10));
insert into TEMP_TABLE values(' xyz ','abc ');
insert into TEMP_TABLE values(' xyzxyz ','abcabc ');
insert into TEMP_TABLE values(' xyz123 ','abc546 ');
insert into TEMP_TABLE values('xyz','abc');
commit
select * from TEMP_TABLE where trim(col1) ='xyz' and trim(col2) ='abc'
desired output
col1,col2
So the correct output is one row, containing these 9 characters
col1,col2which do not appear in the table. is that right?
How is that output related to the data that is in the table? Do you want that output to appear if there are any rows where TRIM (col1) = 'xyz' and TRIM (col2) = 'abc' (for example, either of these two rows from you sample data:
insert into TEMP_TABLE values(' xyz ','abc ');
insert into TEMP_TABLE values('xyz','abc');), and would you want the result set to contain no rows if the table contained no row like that?
If so,
SELECT DISTINCT
'col1,col2' AS desired_output
FROM temp_table
WHERE TRIM (col1) = 'xyz'
AND TRIM (col2) = 'abc'
;I hope this answers your question.
I have a feeling that it doesn't, or perhaps you have more than one question, since this your earlier messages seemed to have something to do with locating text that was surrounded by single-quotes, and the sample data you posted doesn't contain any single-quotes. -
Reference to string from another class
I've searched google and this forum a bit, but can't seem to find an answer. I'd say the thing I'm looking for is really simple and essential, so I must be a moron. But anyways; I want to get the output of the "process" thing in another class. How do I reference to that string fomr outside it's class?
Thanks.
public class ReadInput {
private static void printCommands() {
System.out.println("blabla");
System.out.println("blabla");
System.out.println("blabla");
public static void process(String in) {
Do something with the String "in" here. Say, eventually rename it to "output".
public static void doReadFromStdin() {
try {
BufferedReader inStream = new BufferedReader (
new InputStreamReader(System.in)
String inLine = "";
String in = inLine;
while ( !(in.equalsIgnoreCase("quit"))
!(in.equalsIgnoreCase("exit")) ) {
System.out.print("prompt> ");
in = inStream.readLine();
process(in);
} catch (IOException e) {
System.out.println("IOException: " + e);
public static void main(String[] args) {
printCommands();
doReadFromStdin();
}Maybe this might help
Igor_Pavlove wrote:
public static void process(String in) {
Do something with the String "in" here. Say, eventually rename it to "output".
public static String process(String in){
//Do something, e.g.
String temp = "ifeeltired";
return temp; //Returns the String temp when this method is called.
public static void main(String[] args) {
printCommands();
doReadFromStdin();
public static void main(String[] args){
String temp = "thisisaroughexamples";
String result = this.process(temp); //Returns a string and stores it in result
CreatePlural.print(result); //This is possible because the method print() in CreatePlural is static and an instance of CreatePlural is not required.
}Edited by: Melanie_Green on Feb 2, 2009 6:46 AM
Edited by: Melanie_Green on Feb 2, 2009 6:47 AM -
Copyieng some charecters from string to another string
hi all,
its urgent.
there r two strings
A = 'IEQ0100'.
AA = ' '.
and i want to copy only last 4 charecters from String A to String AA.
could u please help me
thx in advance..........
Sunill =strlen(a).
d = l - 4.
aa1(4) = ad(4).
REPORT zex35 .
DATA : a(7) VALUE 'IEQ0100',
aa(7) VALUE ' '.
DATA : l TYPE i,
d TYPE i.
l = strlen( a ).
d = l - 4.
aa1(4) = ad(4).
WRITE : / aa.
If u dont want first character space in aa then change the below statement
aa1(4) = ad(4).
to
aa0(4) = ad(4)
or
aa = a+d(4).
Maybe you are looking for
-
Fonts garbled in Safari iCloud email.
Since upgrading to Mountain Lion, any time I load icloud in Safari all text under icons, and emails themselves are garbled and illegible. I'm assuming some font that iCloud relies on did not get loaded correctly. I've tried reinstalling Lion,
-
How to know the diferents users in Workbook?
Hi experts, I have a workbook. And I would like to know : - the last user who modify it - the user who created it. thanks a lot. PD : I find the modify user in Transport Managment, when i select the workbook
-
Hide waitcursor during save to file
I have a formt hat has to be run hidden only - there is a save operation that is done for every n seconds and the user cannot see any flicker or wait cursor during this time. Any help appreciated. Thanks. The software is NOT intended for any maliciou
-
Hi All, Is it possible to display Text in smartforms in different angles. Like Vertical... Thanks Kishan
-
Best export option for music video?
Hello, I'm trying to get a music video that my friends' band made in the suitable format (to get it transferred to betamax and handed over to local television stations). The video was actually made in Flash and exported to uncompressed quicktime vide