views:

429

answers:

2

What is the regular expression for replaceAll() function to replace "N/A" with "0" ?

input : "N/A" output : "0"

thanx

+3  A: 

Assuming s is a String.

s.replaceAll("N/A", "0");

You don't even need regular expressions for that. This will suffice:

s.replace("N/A", "0");
cletus
+2  A: 

Why use a regular expression at all? If you don't need a pattern, just use replace:

String output = input.replace("N/A", "0");
Jon Skeet