How to delete space after colon in index entries

This forum is for all Flare issues not related to any of the other categories.
Post Reply
EileenP
Propeller Head
Posts: 78
Joined: Thu Jun 12, 2014 4:34 am

How to delete space after colon in index entries

Post by EileenP »

We had our Flare source files translated into several languages. The source came back with a space after every colon and every semicolon inside the MadCap:keyword tag. The index in the compiled help (CHM in this case) looks fine, but the extra spaces are preventing me from editing keywords in the Index Window as usual. So I am looking for a way to strip out all those spaces -- only the ones after colon and semicolon (in two separate steps if needed) -- between <MadCap:keyword term=" and " />.

I know that we can use RegEx in Flare's Find and Replace in Files function, but I can't figure out how to make Flare leave most of the text alone and only delete the spaces. Can anyone help?

Thanks in advance!
AlexFox
Sr. Propeller Head
Posts: 162
Joined: Thu Oct 19, 2017 1:56 am

Re: How to delete space after colon in index entries

Post by AlexFox »

I've never used any translation functionality in Flare, but I've ventured a little into regexp before. If you can post a few complete strings (complete with offending spaces) in this thread I can take a stab at a statement for you at some point this week.
Last edited by AlexFox on Wed Aug 01, 2018 3:49 am, edited 1 time in total.
EileenP
Propeller Head
Posts: 78
Joined: Thu Jun 12, 2014 4:34 am

Re: How to delete space after colon in index entries

Post by EileenP »

Thank you so much for the offer! Seems like it should be pretty simple, but I don't know how to use RegEx to retain existing text while stripping out unnecessary characters.

(BTW, it's not MadCap's translation functionality that caused the problem. It's the translators' method.)

But anyway, here are some examples of strings where I want the spaces removed:

Code: Select all

<MadCap:keyword term="R-CARD M5 Server (RaServer): yleistä;RaServer: yleistä; työasema (R-CARD M5 -työasema);R-CARD 5000 (laitteisto): yleiskatsaus; Windows-palvelu RaServer: yleistä; R-CARD M5: yleiskatsaus;kulunvalvontajärjestelmä; johdanto" />
<MadCap:keyword term="lisenssien rekisteröinnin peruminen; lisensointi: lisenssien rekisteröinnin peruminen tai hyvitys; lisenssien hyvitys; poisto: lisenssit"/>
All of the strings I'm interested in begin with <MadCap:keyword term="

All of those strings end with " />

And I want to delete all spaces that immediately follow semicolons and colons. No other spaces should be deleted.

To be absolutely clear, this is how the above samples would come out:

Code: Select all

<MadCap:keyword term="R-CARD M5 Server (RaServer):yleistä;RaServer:yleistä;työasema (R-CARD M5 -työasema);R-CARD 5000 (laitteisto):yleiskatsaus;Windows-palvelu RaServer:yleistä;R-CARD M5:yleiskatsaus;kulunvalvontajärjestelmä;johdanto" />
<MadCap:keyword term="lisenssien rekisteröinnin peruminen;lisensointi:lisenssien rekisteröinnin peruminen tai hyvitys;lisenssien hyvitys;poisto:lisenssit"/>
BTW, after tomorrow I'll be out of the office for a few weeks, so if I don't respond right away: THANK YOU!
AlexFox
Sr. Propeller Head
Posts: 162
Joined: Thu Oct 19, 2017 1:56 am

Re: How to delete space after colon in index entries

Post by AlexFox »

So I'm fairly sure you can use the following regexp query to achieve what you're after:

Code: Select all

([:;]{1})\s([^;:/>\s]+)
I'll explain it for anyone who is interested, as I remember a time when regexp was like an alien language to me!

The first [:;] says "either a semicolon or colon" the {1} indicates "exactly one of the preceding character".
The \s immediately after says "any white-space character"
The [^;:/>\s] says not (indicated by the caret) a semicolon, colon, forward slash, greater-than sign or white-space character. This was necessary because of the foreign/unicode characters present in the string.
The () around the first and last parts of the string define capture groups, this allows you to make a backreference to the character(s) that are matched and re-insert them as part of the operation.

To use this in Flare, whilst doing a Regular Expression find/replace, insert the regexp string in the find field and "\1\2" (without quotation marks) in the replace field.

This will basically just strip out any space that immediately follows a colon or semicolon and precedes anything not excluded by the second statement.

Hope this helps!
EileenP
Propeller Head
Posts: 78
Joined: Thu Jun 12, 2014 4:34 am

Re: How to delete space after colon in index entries

Post by EileenP »

Thanks so much for that, AlexFox! Very helpful. (Sorry for the delay -- I was on an extended vacation.)

I'm having to eyeball each and every occurrence, since this finds and replaces *every* occurrence in each topic, and I only want to replace occurrences in index posts. So if there is anyway to limit this to just index posts, that would also be useful.
Post Reply