\hypertarget{interfacedc__string_1_1replace}{}\section{dc\+\_\+string\+:\+:replace Interface Reference}
\label{interfacedc__string_1_1replace}\index{dc\+\_\+string\+::replace@{dc\+\_\+string\+::replace}}
\subsection*{Private Member Functions}
\begin{DoxyCompactItemize}
\item 
recursive character(strlen) function \hyperlink{interfacedc__string_1_1replace_a1a0498975e313f2283c66fb3073527f7}{replace} (string, from, to, recursive, start\+\_\+pos)
\end{DoxyCompactItemize}


\subsection{Detailed Description}


Definition at line 128 of file dc\+\_\+string.\+f90.



\subsection{Constructor \& Destructor Documentation}
\mbox{\Hypertarget{interfacedc__string_1_1replace_a1a0498975e313f2283c66fb3073527f7}\label{interfacedc__string_1_1replace_a1a0498975e313f2283c66fb3073527f7}} 
\index{dc\+\_\+string\+::replace@{dc\+\_\+string\+::replace}!replace@{replace}}
\index{replace@{replace}!dc\+\_\+string\+::replace@{dc\+\_\+string\+::replace}}
\subsubsection{\texorpdfstring{replace()}{replace()}}
{\footnotesize\ttfamily recursive character(strlen) function dc\+\_\+string\+::replace\+::replace (\begin{DoxyParamCaption}\item[{character($\ast$), intent(in)}]{string,  }\item[{character($\ast$), intent(in)}]{from,  }\item[{character($\ast$), intent(in)}]{to,  }\item[{logical, intent(in), optional}]{recursive,  }\item[{integer, intent(in), optional}]{start\+\_\+pos }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Definition at line 1264 of file dc\+\_\+string.\+f90.


\begin{DoxyCode}
1264     \textcolor{comment}{!}
1265     \textcolor{comment}{! 文字列 *string* に文字列 *from* が含まれる場合, その部分を文字列 *to*}
1266     \textcolor{comment}{! に置換して返します. 文字列 *from* が含まれない場合は *string*}
1267     \textcolor{comment}{! をそのまま返します. *from* が複数含まれる場合, 先頭の *from*}
1268     \textcolor{comment}{! のみが置換されます.}
1269     \textcolor{comment}{!}
1270     \textcolor{comment}{! 全ての *from* を *to* へ変換したい場合には,}
1271     \textcolor{comment}{! オプショナル引数 *recursive* に .true. を与えてください.}
1272     \textcolor{comment}{!}
1273     \textcolor{comment}{! デフォルトでは, 文字列の最初から検索を行います.}
1274     \textcolor{comment}{! オプショナル引数 *start\_pos* を与える場合,}
1275     \textcolor{comment}{! *start\_pos* 文字目から検索を行います.}
1276     \textcolor{comment}{!}
1277     \textcolor{comment}{! If a string *from* is included in *string*, the string is}
1278     \textcolor{comment}{! replace to *to*, and the replaced string is returned.}
1279     \textcolor{comment}{! If a string *from* is not included, *string* is returned}
1280     \textcolor{comment}{! without change.}
1281     \textcolor{comment}{! When multiple *from* are included, only first *from* is replaced.}
1282     \textcolor{comment}{!}
1283     \textcolor{comment}{! In order to replace all *from* to *to*, give ".true." to}
1284     \textcolor{comment}{! optional argument *recursive*.}
1285     \textcolor{comment}{!}
1286     \textcolor{comment}{! By default, the string is searched from the top.}
1287     \textcolor{comment}{! If optional argument *start\_pos* is given,}
1288     \textcolor{comment}{! the search is started from *start\_pos*.}
1289     \textcolor{comment}{!}
1290     \textcolor{keywordtype}{use }\hyperlink{namespacedc__types}{dc\_types}\textcolor{keywordtype}{, only}: strlen => \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
1291     \textcolor{keywordtype}{implicit none}
1292     \textcolor{keywordtype}{character(STRLEN)}:: result
1293     \textcolor{keywordtype}{character(*)}, \textcolor{keywordtype}{intent(in)}:: \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}, from, to
1294     \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: recursive
1295     \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)}, \textcolor{keywordtype}{optional}:: start\_pos
1296     \textcolor{keywordtype}{integer}:: sp
1297     \textcolor{keywordtype}{integer}:: i, isa, isb, iea, ieb
1298     \textcolor{keywordtype}{integer}:: ir
1299   \textcolor{keywordflow}{continue}
1300     \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(start\_pos) ) \textcolor{keywordflow}{then}
1301       sp = start\_pos
1302     \textcolor{keywordflow}{else}
1303       sp = 1
1304 \textcolor{keywordflow}{    end if}
1305     \textcolor{keywordflow}{if} ( sp < 1 ) \textcolor{keywordflow}{then}
1306       sp = 1
1307 \textcolor{keywordflow}{    end if}
1308 
1309     result = \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string}
1310     i = index(result(sp:), from)
1311     \textcolor{keywordflow}{if} (i == 0) \textcolor{keywordflow}{return}
1312     i = i + sp - 1
1313     isa = i + len(from)
1314     isb = i + len(to)
1315     \textcolor{keywordflow}{if} (len(to) < len(from)) \textcolor{keywordflow}{then}
1316       iea = len(result)
1317       ieb = len(result) + len(to) - len(from)
1318     \textcolor{keywordflow}{else}
1319       iea = len(result) + len(from) - len(to)
1320       ieb = len(result)
1321 \textcolor{keywordflow}{    endif}
1322     \textcolor{keywordflow}{if} (len(to) /= len(from)) result(isb:ieb) = result(isa:iea)
1323     result(i:i+len(to)-1) = to
1324 
1325     \textcolor{comment}{!-----------------------------------}
1326     \textcolor{comment}{!  再帰的処理}
1327     \textcolor{comment}{!  Recursive process}
1328     ir = index(result(i+len(to):), from)
1329     \textcolor{keywordflow}{if} ( len\_trim(from) == 0 ) \textcolor{keywordflow}{then}
1330       ir = index(trim(result(i+len(to):)), from)
1331 \textcolor{keywordflow}{    end if}
1332     \textcolor{keywordflow}{if} (ir /= 0) \textcolor{keywordflow}{then}
1333       \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(\textcolor{keywordtype}{recursive}) ) \textcolor{keywordflow}{then}
1334         \textcolor{keywordflow}{if} ( \textcolor{keywordtype}{recursive} ) \textcolor{keywordflow}{then}
1335           result = \hyperlink{interfacedc__string_1_1replace}{replace}( \hyperlink{namespacedc__types_adb76910ff05e3b9fe3436567f8f8dac6}{string} = result, &
1336             &               from = from, to = to, &
1337             &               \textcolor{keywordtype}{recursive} = \textcolor{keywordtype}{recursive}, &
1338             &               start\_pos = i+len(to) )
1339 \textcolor{keywordflow}{        end if}
1340 \textcolor{keywordflow}{      end if}
1341 \textcolor{keywordflow}{    end if}
1342 
\end{DoxyCode}


The documentation for this interface was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
dc\+\_\+utils/\hyperlink{dc__string_8f90}{dc\+\_\+string.\+f90}\end{DoxyCompactItemize}
