• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Regular Expression (Find and Replace)

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
PraveenKumarGautam
Asked:
PraveenKumarGautam
  • 5
  • 4
1 Solution
 
CEHJCommented:
You don't even need a regex for that:
line = line.replace("5,939", "5939");

Open in new window

0
 
PraveenKumarGautamAuthor Commented:
I need a regular expression that can work in Notepad++ for this data
0
 
PraveenKumarGautamAuthor Commented:
I just want to do the similar find and replace(as mentioned in the question) in the whole file
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
for_yanCommented:
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
 
PraveenKumarGautamAuthor Commented:
Yes I am looking for a general pattern
0
 
CEHJCommented:
Try
String PAT = "(\"\\d+),(\\d+\")";
line = line.replaceAll(PAT, "$1$2");

Open in new window

0
 
CEHJCommented:
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
 
PraveenKumarGautamAuthor Commented:
I tried the same in Notepad++ but it is replacing the numbers with $1$2 rather then the desired results
0
 
CEHJCommented:
It would be more like what i posted here http:#35218809
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now