Here you can find the source of replace(String operateOn[], String from, String to)
Parameter | Description |
---|---|
operateOn | the operate on |
from | the from |
to | the to |
public static void replace(String operateOn[], String from, String to)
//package com.java2s; /*/* www.j ava2s . c o m*/ DA-NRW Software Suite | ContentBroker Copyright (C) 2013 Historisch-Kulturwissenschaftliche Informationsverarbeitung Universit?t zu K?ln This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { /** * Iterates over the items in operateOn and replaces any matches * of from to to. * * @param operateOn the operate on * @param from the from * @param to the to * @author Daniel M. de Oliveira */ public static void replace(String operateOn[], String from, String to) { for (int i = 0; i < operateOn.length; i++) { Pattern patternOutput = Pattern.compile(from); Matcher matcherOutput = patternOutput.matcher(operateOn[i]); operateOn[i] = matcherOutput.replaceFirst(to); } } }