473,508 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replace dot in a String.

dmjpro
2,476 Top Contributor
I want to replace dot in a String.
I used String.replaceAll ..but due to regular expression .... I couldn't find out the solution.
I used String.replaceAll(".","something");
But in regular expression "." has a special meaning .....

Debasis Jana
Feb 15 '08 #1
2 40907
JosAH
11,448 Recognized Expert MVP
A backslash removes any special meaning from regular expression (meta) characters
so feed it a \. (backslash dot). Note that if you want to construct a literal String
for that you need to escape the backslash again to keep javac happy, so you
need to type "\\." (backslash backslash dot).

kind regards,

Jos
Feb 15 '08 #2
BigDaddyLH
1,216 Recognized Expert Top Contributor
I think I've posted the following comment a hundred times in various forms, but here goes #101: don't let String's replaceAll blind you to the existence of String's replace: it is a simpler version that doesn't involve regular expressions, so you don't have to wring your hands with worry about special regular expression characters. Calling it is easy:
Expand|Select|Wrap|Line Numbers
  1. String result =s.replace(".", "something");
Yes, it does replace *all* instances of '.' with 'something':
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
http://java.sun.com/javase/6/docs/ap....CharSequence)
Feb 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3666
by: beliavsky | last post by:
The code for text in open("file.txt","r"): print text.replace("foo","bar") replaces 'foo' with 'bar' in a file, but how do I avoid changing text inside single or double quotes? For making...
7
2222
by: ajikoe | last post by:
Hello, I would like to replace string with different values, For example : source = 'kode1 bla bla kode1 bla kode1' I have a list with each member will replace each of kode1. L = So the new...
1
1723
by: Neil Zanella | last post by:
Hello, The MSDN documentation does not seem to mention whether the Replace string method returns a new string or modifies the existing string in place and then returns it. I would like to know...
2
1998
by: Dmitriy Kolesnik | last post by:
Hello, all! I don't know how I can replace specified string in the txt-file from one to another. Thank You. -- __________________
6
1472
by: localhost | last post by:
I have a string that looks like this: "document.form1.textBox1.focus ();document.form1.textBox1.select();" I want to replace the text between "document.form1." and ".focus()", as well as...
21
3356
by: gary | last post by:
How would one make the ECMA-262 String.replace method work with a string literal? For example, if my string was "HELLO" how would I make it work in this instance. Please note my square...
0
3067
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not...
3
3938
by: Hvid Hat | last post by:
Hi I want to highlight (make it bold) a word in some text I'm getting in XML format. My plan was to replace the word with a bold (or span) tag with the word within the tag. I've found the code...
5
2566
by: Unknown | last post by:
Hi, I've got this code : cb = open("testfile", "r+") f = cb.readlines() for line in f: rx = re.match(r'^\s*(\d+).*', line) if not rx: continue else:
3
4010
by: omar999 | last post by:
im trying to replace NULL with N/A but I think I have a syntax error .. how do you replace string on recordset via classic asp so on objRS17and18("Price_Band_1") should it be something like ...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.