|
| ||||||||||
| Tags: backslash, datatype, integer, regulare expression, slash, special characters, string |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Replace backslash in a string
I must insert in my database for a string containing the backslash \ and when reregistration in ABSE data s nothing displays. So I try to do this: Code: Code: myText.replaceAll("\\","\\\\"); |
|
#2
| |||
| |||
| Re: Replace backslash in a string
Hello, If I am not wrong then you are getting the following error. Code: java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ |
|
#3
| |||
| |||
| Re: Replace backslash in a string
Hello, Just in case you do this well in your code: Code: myText = myText.replaceAll("\\", "\\\\"); |
|
#4
| |||
| |||
| Re: Replace backslash in a string
Hello, Even I was trying a similar kind of a program , And even i get a same error , i have no idea what this error means. So, please if you have any idea then even i am the interested candidate. Here is what I get Code: java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.compiles(Unknown Source) at java.util.regex.Pattern. <init>(Unknown Source) at java.util.regex.Pattern.compiles(Unknown Source) at java.lang.String.replaceAll(Unknown Source) |
|
#5
| |||
| |||
| Re: Replace backslash in a string
Hello, I have a code with me and i think you guys will be interested to see this Here is the code: Code: public class Replace
{
public static void main(String[] args)
{
String str = "abc";
String rep = str.replaceAll("abc", "c:\\\\test\\\\abc");
System.out.println(rep);
}
} |
|
#6
| |||
| |||
| Re: Replace backslash in a string
Hello, I think the most important in such programs is to do the loop, what I am saying is this Code: loop check:
for (int i=0; i<inputString.length(); i++){
char chval = inputString.charAt(i);
if (chval=='\\'){
return false;
}
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Replace backslash in a string" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Regex replace an integer with string | New ID | Software Development | 5 | 05-02-2010 12:35 AM |
| Find and Replace in JavaScript String | Wilbur | Software Development | 5 | 15-12-2009 01:23 PM |
| Simple string replace in php | cyber-noob | Software Development | 3 | 30-11-2009 12:37 PM |
| Replace backslash with forward slash in Perl | _Gentoo_Nile_ | Software Development | 3 | 03-08-2009 10:02 PM |
| Replace a string in multiple files Linux | ADISH | Tips & Tweaks | 0 | 27-06-2009 10:07 AM |