Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

replace function help


replace function help

Hi Folks,

I have a situation where we publish documents in both French and English. In French, we use the male ordinal character (ordm - º) frequently when stating think like No 1, No 2, etc. My organization has a preference to not have the 'o' part of the numero underlined - and our font set has it underlined as part of the character.

Our solution is basically to substitute a different font for that one character (like Times where the male ordinal does not have a line under it).

In areas of our document where text is gentext, we have an APP override to change the font, but in the general text of the document (like in paragraphs etc), we were just going to use a font override. I would rather not have every element of the style sheet overridden this way as it is very cumbersome.

I was trying to automate it using the replace function with something like the following:

' First replace any cases of the male ordinal with font markup with just the male ordinal (I do this so we don't keep adding multiple level of font override tags if this is run multiple times)

replace('<?Pub _font FamName="Times New Roman"?>º<?Pub /_font?>','&ordm;',0x20B0) <<- This one does not work

' Then replace all cases of the male ordinal with the male ordinal wirth the font markup.

replace('&ordm;','<?Pub _font FamName="Times New Roman"?>&ordm;<?Pub /_font?>',0x20B0) <<- This one works

When I use the GUI Find/Replace function with the string in the first statement, it also doesn't work properly (ans yes I have the 'Match Markup' selected)

When I edit source it also does not find the text, if I use Windows Notepad, the search and replace works (I was just testing). Does anyone have any suggestions on how to get this to work in Arbortext?

Thanks in advance for any suggestions or other ideas,



If you are only worried about this for printed outputs and you are using APP (or Styler/APP) for printed outputs then there are a few options I can think of with APP overrides.

With that approach the character will be left untouched except that, at the last moment as your PDF is being generated, the fonts will be switched for that one character. Alternatively you could build your own oridinal indicator using the "o" glyph from your usual font but forced to the superscript position (or substitute the degree symbol, or ...).

The best way to gather ideas and code snippets for this would be via a question to the APP user group (google for "yahoo 3b2users").



Hi Rob--

There are a couple of quirks about Arbortext's find feature when it comes to matching markup:

1) For it's internal "Pub" processing instructions, it aliases them to a pseudo-element with the name immediately following the PI name. In this case, it thinks of <?Pub _font ....?> as if it were "<_font>"

2) It doesn't like attribute values in search markup strings, probably because in the internal document model, attributes are unordered, so searching for "<foo a='bar' b='baz'>" would also need to match "<foo b='baz' a='bar'>", which gets complicated when you have a large number of attributes.

The implication of these together is that you can find the things you're looking for using something like this:


If you *really* want to make sure you are only getting the ones that are labeled as Times New Roman, you might need to use XPath for that, something like this:

oid_xpath_nodeset(oid_root(), $ordms, "//_font[@FamName='Times New Roman' and .='º']);

for (ordm in ordms) {

oid_delete(ordms[ordm], 0x1) # 0x1 = delete tag but preserve content


As Gareth points out, however, there are probably better approaches that don't require you to modify your markup every time you publish. Probably the easiest would be to modify your file to remap the ordm character to the degree character (0xB0). Check the comments in $ARBORTEXT/lib/, make a copy in your custom directory, and change the line where ordm is defined so it maps to Unicode 0xB0 instead.



Top Tags