Files
help/source/text/sbasic/shared/replace.xhp
Ilmari Lauhakangas 7e42394ecb tdf#152323 drop name attribute from <link> elements
Replacement done with

find . -name \*.xhp -print0 |xargs -0 -P 0 perl -CS -pi -e \
        's#(<link[^>]*?) +name *="[^"]*" *( [^>]+|) *>#$1$2>#g'

(note some inconsistencies with space between name and = and also having
empty value, and some more complicated expression to also clear up
double space before/after the attribute)

translation files will be prepped with:

find */helpcontent2 -name \*.po -print0 |xargs -0 -P 0 perl -CS -pi -e \
    $'s#(<link[^>]*?) +name=(?:\\\\"[^"]*\\\\"|\'[^\']*\') *( [^>]+|) *(/?>)#$1$2$3#g unless /^#/'

(note that not all languages use the " as quote character for the
attributes, but that also single quotes appera in the po file. Hence
the use of the shell $'string' syntax to be able to quote ' as \'
It also requires to quote the backslash, so that it needs to be escaped
once for the shell, then another time for perl. Also don't work on
obsolete strings (those are prefixed with #~ in the po files)
Also note that <link..></link> gets turned into <link ../> during
translation extraction (along with removal of the space between the
attribute name and the value), so the pattern needs to be slightly
different here)

Change-Id: I95e53a08e6b0095cd894109ea0de154cc4859d8f
Reviewed-on: https://gerrit.libreoffice.org/c/help/+/143713
Tested-by: Jenkins
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
2022-12-07 17:39:02 +00:00

63 lines
4.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<meta>
<topic id="sbasicsharedreplace" indexer="include" status="PUBLISH">
<title id="tit" xml-lang="en-US">Replace Function</title>
<filename>/text/sbasic/shared/replace.xhp</filename>
</topic>
</meta>
<body>
<section id="replace">
<bookmark xml-lang="en-US" branch="index" id="bm_id721552551162491">
<bookmark_value>Replace function</bookmark_value>
</bookmark>
<h1 id="hd_id781552551013521"><link href="text/sbasic/shared/replace.xhp">Replace Function</link></h1>
<paragraph id="par_id291552551013522" role="paragraph">Replaces some string by another.</paragraph>
</section>
<embed href="text/sbasic/shared/00000003.xhp#functsyntax"/>
<bascode>
<paragraph role="bascode" localize="false" id="bas_id51623159758550">Replace (Expression As String, Find As String, Replace As String [, Start = 1 [, Count = -1 [, Compare = True]]]) As String</paragraph>
</bascode>
<embed href="text/sbasic/shared/01020300.xhp#kwargs"/>
<embed href="text/sbasic/shared/00000003.xhp#functvalue"/>
<paragraph role="paragraph" id="par_id911552552252024">String</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#functparameters"/>
<paragraph role="paragraph" id="par_id721552552263062"><emph>Expression:</emph> Any string expression that you want to modify.</paragraph>
<paragraph role="paragraph" id="par_id901552552269836"><emph>Find:</emph> Any string expression that shall be searched for.</paragraph>
<paragraph role="paragraph" id="par_id791552552275383"><emph>Replace:</emph> Any string expression that shall replace the found search string.</paragraph>
<paragraph role="paragraph" id="par_id111552552283060"><emph>Start:</emph> Optional numeric expression that indicates the character position where the search starts and also the start of the substring to be returned.</paragraph>
<paragraph role="paragraph" id="par_id921552552289833"><emph>Count:</emph> Optional maximum number of times the replace shall be performed. When set to -1, all possible replacements are performed.</paragraph>
<paragraph role="paragraph" id="par_id891552552302894"><emph>Compare:</emph> Optional boolean expression that defines the type of comparison. The value of this parameter can be <literal>True</literal> or <literal>False</literal>. The default value of <literal>True</literal> specifies a text comparison that is not case-sensitive. The value of <literal>False</literal> specifies a binary comparison that is case-sensitive. You can as well use 0 instead of <literal>False</literal> or 1 instead of <literal>True</literal>.</paragraph>
<embed href="text/sbasic/shared/00000003.xhp#errorcode"/>
<embed href="text/sbasic/shared/00000003.xhp#err5"/>
<embed href="text/sbasic/shared/00000003.xhp#functexample"/>
<bascode>
<paragraph role="bascode" id="par_id991552552420717">MsgBox Replace ("aBbcnnbnn", "b", "$", 1, 1, False) 'returns "aB$cnnbnn"</paragraph>
<paragraph role="bascode" id="par_id321552552440672" xml-lang="en-US">REM meaning: "b" should be replaced, but</paragraph>
<paragraph role="bascode" id="par_id571552552467647" xml-lang="en-US">REM * only when lowercase (compare=False), hence second occurrence of "b"</paragraph>
<paragraph role="bascode" id="par_id71552552474769" xml-lang="en-US">REM * only first (respecting case) occurrence (count=1)</paragraph>
<paragraph role="bascode" id="par_id501587778372566" localize="false">MsgBox Replace ("ABCDEFGHI", "E", "*", 4)</paragraph>
<paragraph role="bascode" id="par_id861587778446685" xml-lang="en-US">REM returns D*FGHI because the search starts at position 4, which is also the start of the returned string.</paragraph>
<paragraph role="bascode" id="bas_id491622734884707" xml-lang="en-US">MsgBox Replace("aBbcnnbnn", "b", "$£", compare:=False) 'returns "aB$£cnn$£nn"</paragraph>
<paragraph role="bascode" id="bas_id341622734993202" xml-lang="en-US">REM Replace all (count = -1) "b" with "$£" respecting casing (compare=False) starting from first letter (start=1) </paragraph>
</bascode>
<section id="relatedtopics">
<paragraph role="paragraph" id="par_id161599082457466" localize="false"><embedvar href="text/sbasic/shared/00000003.xhp#stringfunctions"/></paragraph>
<paragraph role="paragraph" id="par_id361623159933508" localize="false"><embedvar href="text/sbasic/shared/03/sf_string.xhp#StringService"/></paragraph>
</section>
</body>
</helpdocument>