Remove part of a string
Hey All Gurus,
I have a string IEQUS94 I want to remove ieq from the string... how to do that?? Any thoughts!!
Will reward point... for sure!
Thanks Nina.
There is a few ways to do this depending on some assumptions.
Assumption 1, that IEQ is always the first 3 characters. If that is the case.....
data: str type string.
str = 'IEQUS94'.
shift str left by 3 places.
Regards,
Rich Heilman
Similar Messages
-
This is currently what I have:
String[] song = GUI.currentPlaylistItems.get (i).toString ().split (" - ");Let's say the Object I am splitting is: Incubus - Drive (3:52)
When splitting that I will have:
song[0] = Incubus
song[1] = Drive (3:52)
What should I do to get rid of the (3:52)? Splitting song[1] at a ( doesn't seem very efficient. Is there a better approach? It's too late to think properly right now, but I can't sleep until I figure it out.You can use a Stringtokenizer instead of split of
String class.Well, as doc says: StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.
eg:
import java.util.StringTokenizer;
public class TestToken {
public static void main(String args[])
String
str="abc;def;hij;klm;nop-aaa-jjj-ooo";
System.out.println("Using split() of String
class");
String[] song = str.split(";");
for(int i=0;i<song.length;i++)
System.out.println(song);
StringTokenizer st=new StringTokenizer(str,"-;");
System.out.println("Using String Tokenizer");
while(st.hasMoreElements())
System.out.println(st.nextElement());
Is it related to OP's issue ?
Note that in your example, you might (should?) use :String[] song = str.split("[;-]"); -
Remove $%&* characters from a String
Hi,
I have the following program that is supposed to detect a subsequence from a String (that contains $ signs) and remove it. This is a bit tricky, since because of $ signs, the replaceAll method for String does not work. When I use replaceAll for removing the part of the String w/ no $ signs, replaceAll works perfectly, but my code needs to cover the $ signs as well.
So far, except for replaceAll, I have tried the following, with the intent to first remove $ signs from only that specific sequence in the String (in this case from $d $e $f) and then remove the remaining, which is d e f.
If anyone has any idea on this, I would greatly appreciate it!
Looking forward to your help!
public class StringDivider {
public static void main(String [] args)
String symbols = "$a $b $c $d $e $f $g $h $i $j $k l m n o p";
String removeSymbols = "$d $e $f";
int startIndex = symbols.indexOf(removeSymbols);
int endIndex = startIndex + removeSymbols.length()-1;
for(int i=startIndex;i<endIndex+1;i++)
if(symbols.charAt(i)=='$')
//not sure what to do here, I tried using replace(oldChar, newChar), but I couldn't achieve my point, which is to
//delete $ signs from the specific sequence only (as opposed to all the $ signs)
System.out.println(symbols);
}A little modification on the last version:
This one's more accurate.
public class StringDivider {
public static void main(String [] args){
String symbols = "$a $b $c $d $e $f $g $h $i $j $k l m n o p";
String removeSymbols = "$d $e $f $g";
if(symbols.indexOf(removeSymbols)!=-1)
if(removeSymbols.indexOf("$")!=-1)
removeSymbols = removeSymbols.replace('$', ' ').trim();
removeSymbols = removeSymbols.replaceAll("[ ]+", " ");
String [] symbolsWithoutSpecialChars = removeSymbols.split(" ");
for(int i=0;i<symbolsWithoutSpecialChars.length;i++)
symbols = symbols.replaceAll("[\\$]*"+symbolsWithoutSpecialChars, "");
symbols = symbols.replaceAll("[ ]+", " ");
else
symbols = symbols.replaceAll(removeSymbols, "");
symbols = symbols.trim();
System.out.println(symbols); -
it sounded prettty easy..
I know the first part of my String is <html><center><p> and the last part is </p></center></html>
but for saving it into the database I want to remove the HTML parts..
I know how much characters the html stuff is.. I know what the html is.. how do I remove it from my string?If your String always starts with <html><center> and always ends with </center></html> you can use:
int startLength = "<html><center>".length();
int endLength = "</center></html>".length();
String withoutHtml = myString.substring(startLength, myString.length() - endLength); -
How can I reset Safari with all components? On my MacBook with Lion, Safari does not start, does not react immediately after trying to open it. Installing a new Safari does not help. Removing parts of Safari in the Library does not help. Where can I find and remove all components as LastSession and TopSites?
The only way to reinstall Safari on a Mac running v10.7 Lion is to restore OS X using OS X Recovery
Instead of restoring OS X in order to reinstall Safari, try troubleshooting extensions.
From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.
If it's not an extensions issue, try troubleshooting third party plug-ins.
Back to Safari > Preferences. This time select the Security tab. Deselect: Allow plug-ins. Quit and relaunch Safari to test.
If that made a difference, instructions for troubleshooting plugins here.
If it's not an extension or plug-in issue, delete the cache.
Open a Finder window. From the Finder menu bar click Go > Go to Folder
Type or copy paste the following
~/Library/Caches/com.apple.Safari/Cache.db
Click Go then move the Cache.db file to the Trash.
Quit and relaunch Safari to test. -
Converting part of the string to a date and subtract with sysdate.
HINT! In order solve this you must know how the pnr is assembled. Study this:
650323-5510, we only need the first six characters. They inform us about when the person (car owner) was born. In this case it is 23 Mars 1965. You have to use several oracle built-in-functions to solve this. Hint! Begin by converting part of the string to a date and subtract with sysdate.
select to_char(to_date(cast(pnr,'YYMMDDMM'))) from car_owner;
please what am i doing wrong. i need the result to be something like this
Hans, Rosenboll, 59,6 years.Hi.
The main problem here is you have only last two digits of year. That could be the problem in a couple of years from now, when somebody born after 2k would get in to your database. For now if we ignore this problem the right solution would be :
<code>
SELECT months_between(trunc(SYSDATE),
to_date('19' || substr('650323-5510',
1,
6),
'YYYYMMDD')) / 12 years_old
FROM dual
</code>
Suppose you are expecting the age of the car owner as a result above code will give you that. One again notice the '19' I appended.
Best regards. -
Replacing a part of a String with a new String
Hi everybody,
is there a option or a method to replace a part of a String with a String???
I only found the method "replace", but with this method I only can replace a char of the String. I don't need to replace only a char of a String, I have to replace a part of a String.
e.g.:
String str = "Hello you nice world!";
str.replace("nice","wonderfull"); // this won't work, because I can't replace a String with the method "replace"
// with this method I'm only able to replace charsDoes anyone know some method like I need???
Thanks for your time on answering my question!!
king regards
IceCube-Ddo check java 1.4 api, I think there is a method in it, however for jdk1.3 you can use
private static String replace(String str, String word,String word2) {
if(str==null || word==null || word2 == null ||
word.equals("") || word2.equals("") || str.equals("")) {
return str;
StringBuffer buff = new StringBuffer(str);
int lastPosition = 0;
while(lastPosition>-1) {
int startIndex = str.indexOf(word,lastPosition);
if(startIndex==-1) {
break;
int len = word.length();
buff.delete(startIndex,startIndex+len);
char[] charArray = word2.toCharArray();
buff.insert(startIndex,charArray);
str = buff.toString();
int len2 = startIndex+word2.length();
lastPosition = str.indexOf(word,len2);
return buff.toString(); -
How to remove the comma from string
Hi,
I Have string like below :
String some1="123,44.22";
I want to remove comma from string and final output should be 12244.22.
public class getOut{
public static void main(String args[]){
String some1="123,44.22";
getChars(int 0,some1.length(),char[] dst,0);
can somebody in the forum give me idea how to remove comma from the String and
have a string without comma.
Thanks
Jackint idx = oldString.indexOf(',');
if(idx >= 0)
newString = oldString.substring(0, idx) + oldString.substring(idx + 1);or for jdk 1.4 and later
str = str.replaceAll(",", ""); -
Hello!
I've recently started experimenting and toying around with Photoshop CS3, mainly for things I have to do for work. I've got a poster I've inserted onto a template so I have two layers. I'm just wondering how to remove parts of the image, in this case the text and just leave the background of the poster on it's own. The image is all one layer, placed into the template from a .pdf file. I've managed to get away with editing things like logos, text on previous posters I've edited using the Liquify tool but I really dont want to distort the image that the text sits in front of.
Any feedback/help would be hugely appreciatedScott,
The process will depend on exactly how things exist in your image.
As CurtY mentions, if the text and the background are one, i.e. they have been merged into one Layer, the only option is to Select (Tool of choice, but I'd probably opt for the Rectangular Marquee), and Delete that Selected area. However, you will leave a hole, as the merged background no longer exists in that area. To "fill" that hole, the Clone Tool and the Healing Brush will be very helpful, but you will need enough of that background to work with. May be easy, or tedious.
Can you post a screen-cap with your Image Open and the Layers Palette visible? That will tell us a lot about what you have, and someone can direct you. This ARTICLE might be useful for doing the screen-cap.
Good luck,
Hunt -
I was cleaning up the programs on my hard drive and removed Photoshop Elements 9 and 10. I used Revo Uninstaller Pro to remove all the left over files and registry entries. Revo also removed parts of my version 12. I re-downloaded the demo version again as I already have the serial number. When I run the install program files my only choice is to remove version 12 and I'm not able to install
Try this,
Run the cleaner tool. clean the product(if you see).
Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
Then Rename/delete all the Adobe folders.
The locations are: 64 bit computer.
C:\Program Files (x86)\Common Files\Adobe.
32 bit computer.
C:\Program Files \Common Files\Adobe.
C:\ProgramData\Adobe.
You also have Adobe folders in :
C:\Users\[user name]\AppData\Local\Adobe
C:\Users\[user name]\AppData\Locallow\Adobe
C:\Users\[user name]\AppData\Roaming\Adobe\OOBE
Then Re-install the product. -
Use removable part from iPod charger for MacBook?
I was wondering if I can use the removable part of the old iPod charger for my MacBook charger instead of the extension cord.
I work with a plug 20 cm away from my MacBook, so I don't really want all the cables on my desk.No. No part from a iPad charger will work with a Mac notebook. All you are asking for is Trouble. Move your desk closer to an AC outlet.
-
wondering.. anyone knows how to remove characters in a string
e.g.
string: applepie
after removing last 3 chars become "apple"
thanks...That of course will only work for this example. Better solution is to use indexOf() to locate the position of the string you wish to remove. If the string you wish to remove is in the middle, then you will have to do a bit of extra work and concat two substrings.
-
How to remove new line from string
I have a string say following
String line = "one\ntwo\nthree";Now i am trying to remove new line from string. For this i did following
String txt = line.replaceAll("\\n","");But i see still new line is occuring. Is it correct way. Please advice me.Ok. I was just using \n instead of \r\n. And i am in windows. I will give a try with \r\n
Ok i tried using following , but it doesnt work.
line = line.replaceAll("\\r\n","");Am i missing anything here. Please guide me.
Edited by: ArpanaK on Oct 8, 2007 4:44 PM -
JAXB unmarshalling error for " " token as part of xsd:string type element
JAXB unmarshalling error for "<" token as part of xsd:string type element
We are getting a JAXB unmarshalling error:
while processing the following <condition> tag which is of type xsd:string
<condition> x < 100 </condition>
The error is probably happening due to "<" token as a part of string type.
xml.bind.JAXBException: Unexpected error in Unmarshalling
at oracle.xml.jaxb.JaxbUnmarshaller.unmarshal(JaxbUnmarshaller.java:224)
Any ideas how to resolve this issue?
Note
<condition> x > 100 </condition> is getting unmarshalled successfully by JAXB unmarshaller.
ThanksHi,
Did you tried to put & lt; (without space) instead of < ?
Best Regards,
Paweł -
Addressing of part of the string in the container
Hello,
in a mail task I would like to print only some characters from a string - e.g. from second to tenth - is it possible to address some part of the string in the container as is usual in abap?
thx,
JJHi,
Yes , it is possible. If you want to show only some part of the string value in mail description you can use normal abap string operations. For example: In Mail description if you want to show only a part variable VALUE. you can just use &VALUE+a(b)&. It will work !!
You can try it out !!
Regards
Krishna Mohan
Maybe you are looking for
-
Calling a TextFields get method from another class as a String
This is my first post so be kind.... I'm trying to create a login screen with Java Studio Creator. The Login.jsp has a Text Field for both the username and password. JSC automatically created get and set methods for these. public class Login extends
-
Adding fields to ALV output list in Tcode S_ALR_87012357
Hi, I need your help to insert new fields in output at standard t-code S_ALR_87012357 for GST Report. Report name is RFUMSV00. The add/insert columns are 1)Vendor Description, 2)SGD Gross Amt(100% tax Reporting curr) 3)SGD Tax Base Amt(100% Tax Repo
-
I have a 2009 Macbook 13 inch that I have gotten to connect to my Vizio TV through an HDMI cable for the picture. The guy at best buy told me I would need an audio cable from my macs headphone jack to my tv's audio spots. I hooked that up and nothing
-
Finder crashes whenever a downloaded file gets chosen to "Show In Finder"
It happens after some files are downloaded, and it doesn't matter what type of files they are. If there is a folder open on the desktop and the downloads window is open, ctrl + click the file, choose "show in finder" and the folders all reset to show
-
My daughter's iPod touch has been disabled by trying password too many times. When it is turned on"iPod is disabled connect to iTunes". But iTunes will not recognise iPod. It has never been backed up. I want to wipe it clean and restore it to factory