?
Solved

Regular Expression (Find and Replace)

Posted on 2011-03-25
10
Medium Priority
?
272 Views
Last Modified: 2012-05-11
Hi,

In one of my file I have the data as below

04001-AP107-6718,2005,"5,939",0,0,"5,939","6,117","2,630",10.52,

here I would like to replace "5,939" with "5939".

Please suggest a way out.
0
Comment
Question by:PraveenKumarGautam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 35218582
You don't even need a regex for that:
line = line.replace("5,939", "5939");

Open in new window

0
 

Author Comment

by:PraveenKumarGautam
ID: 35218592
I need a regular expression that can work in Notepad++ for this data
0
 

Author Comment

by:PraveenKumarGautam
ID: 35218614
I just want to do the similar find and replace(as mentioned in the question) in the whole file
0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 47

Expert Comment

by:for_yan
ID: 35218668
Notepad really works in this way withou problems - you put the Find box "5,939" in the replace box: "5939" and replace all will work
Do you mean you want to follow the general pattern als replacing "6,110" with "6110", etc - ?
0
 

Author Comment

by:PraveenKumarGautam
ID: 35218721
Yes I am looking for a general pattern
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35218791
Try
String PAT = "(\"\\d+),(\\d+\")";
line = line.replaceAll(PAT, "$1$2");

Open in new window

0
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 total points
ID: 35218809
In an editor that would (if it allows it) would be something like
Find: ("[0-9]+),([0-9]+")
Replace: \1\2

Open in new window

0
 

Author Comment

by:PraveenKumarGautam
ID: 35218872
I tried the same in Notepad++ but it is replacing the numbers with $1$2 rather then the desired results
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35218881
It would be more like what i posted here http:#35218809
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35219573
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question