• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regex to use in replaceall  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I want to add newline after occurence of IPV4 address in my string. I am trying with output.replaceAll("?<=(\\d{1,3}\\.){3}\\d{1,3}", "\n");
But it is throwing Exception. Please help me.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ram ank wrote:But it is throwing Exception. Please help me.


You need to TellTheDetails(⇐click)

Copy/paste the exact, complete error message, as well as the line of code that caused it.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing jumps out at me though. As far as I know, you have to do

not just

 
Ram ank
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked like this
with ?<ip> it stores the matching string and using it in replacement with ${ip}

output.replaceAll("(?<ip>(\\d{1,3}\\.){3}\\d{1,3})", "${ip}\n");

Thank you guys
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!