Hallo,
> kann man in FM (7.2 Win) reguläre Ausdrücke zum Suchen & Ersetzen verwenden?
>
> Dabei geht es mir hauptsächlich um die Gruppierung von Teil-Strings:
>
> Suche nach: {\(IrgendeinText\)|\(NochEinText\)}
>
> Ersetze durch: [\1 \2]
>
> um z. B. zwei Textblöcke in einer geschweiften Klammer, getrennt durch
> irgendwelchen Whitespace zu ersetzen durch
> die zwei Texte in einer eckigen Klammer, mit genau einem Leerzeichen
> dazwischen
Suchen/Ersetzen von Text mit regulären Ausdrücken in
einer MIF-Datei hat seine Tücken. Was du beachten musst:
o Umlaute haben eigene Codes (siehe Character_Sets.pdf)
o Wörter können mit Bindestrich auf mehrere Zeilen
umgebrochen sein, da Text in der MIF-Datei genauso steht
wie in der FrameMaker-Datei.
Mit Hilfe von FrameScript kann man auch reguläre Ausdrücke
suchen/ersetzen. Unten angehängt ist eine E-Mail dazu von
Rick Quatro, in der er dazu ein Beispiel gibt.
Viele Grüße
Winfried
---
To expand on Klaus's answer, here is a way to use regular expressions to just
remove bracketed text from a variable definition. This illustrates the power
and usefulness of the EActiveXObject in FrameScript. Although regular
expressions are not native to FrameScript, you can "grab" the VBScript.RegExp
object and use it in FrameScript. The VBScript.RegExp object should be
available in any Windows computer that has Internet Explorer 5.5 or higher
installed. Regular expressions allow you to do complex pattern matching in text.
For more information about regular expressions, see
http://www.regular-expressions.info/. A great tool for working with regular
expressions is RegexBuddy at http://www.regexbuddy.com.
Here is what the regular expression "<[^>]+>" means:
Match the character "<" literally, then
Match any character that is not a ">", between one and unlimited times, then
Match the character ">" literally
Here is the script:
Set sFmt = '<Blue20%>40</>03<Pantone 137 CVC>29<Default ¶ Font>';
// Initialize a regular expression object.
Set oRegex = InitializeXObject{'VBScript.RegExp'};
If oRegex = 0
LeaveSub;
EndIf
// Set the regular expression parameters.
// Match along the entire string.
Set oRegex.Global = True;
// Set the pattern to match.
Set oRegex.Pattern = '<[^>]+>';
// Test for a match.
If oRegex.Test{sFmt}
// Execute all matches along the string.
Set oMatch = oRegex.Execute{sFmt};
// Loop through the matches.
Loop While(i < oMatch.Count) LoopVar(i) Init(0) Incr(1)
// Replace the match with nothing.
Set sFmt = eStr.ReplaceFirst{sFmt,oMatch[i].Value,''};
EndLoop
EndIf
Display sFmt;
Function InitializeXObject sProgId
//
Local Result(0);
// Create the object.
New EActiveXObject NewVar(Result) ProgId(sProgId);
If Result.ErrorCode <> 0
Write Console sProgId + ' could not be initialized.';
Write Console 'ErrorCode: '+Result.ErrorCode;
Set Result = 0;
EndIf
//
EndFunc //--------------------------------------------------------------------
Rick Quatro
Carmen Publishing
585-659-8267
www.frameexpert.com
_______________________________________________
Talk mailing list
[email protected]
http://lists.framemaker.de/mailman/listinfo/talk