Case sensitive sandr?

Post Reply
greer
Posts: 10
Joined: Mon Nov 01, 2010 12:49 pm

Case sensitive sandr?

Post by greer »

To cater for certain foreign character words, we use an XML file of search and replace terms to switch out on our website, (for example, "sister" in French is "sœur"):

soeur => sœur

However, "Nunn" in French is "Sœur", (with an uppercase S), but due to the case-insensitive sandr, is also getting replaced with "sœur", (lowercase s). Here is our code:

<$file = "oelist.xml">
<read $file>
<$data = $ret>
<rex row ">><term>\P=!</term>+\F</term>" $data>
<$term = $ret>
<rex ">><termid>\P=!</termid>+\F</termid>" $term>
<$needles = $ret>
<rex ">><termuc>\P=!</termuc>+\F</termuc>" $term>
<$replace = $ret>
<sandr $needles $replace $TEXT>
<$TEXT = $ret>
Here is the structure of our xml file:
<term><termid>boeuf</termid><termuc>bœuf</termuc></term>
<term><termid>coeur</termid><termuc>cœur</termuc></term>
<term><termid>soeur</termid><termuc>sœur</termuc></term>
<term><termid>Soeur</termid><termuc>Sœur</termuc></term>
etc...

Is there an efficient way to perform this function with case sensitivity, (so that "soeur" becomes "sœur" and "Soeur" becomes "Sœur")?

Thanks!
User avatar
Kai
Site Admin
Posts: 1271
Joined: Tue Apr 25, 2000 1:27 pm

Case sensitive sandr?

Post by Kai »

Prepend `\R' to your search expressions; then they will respect case. E.g. after you get $needles:

<sandr ">>=.+" "\\R\2" $needles>
<$needles = $ret>
User avatar
John
Site Admin
Posts: 2597
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH
Contact:

Case sensitive sandr?

Post by John »

The other thing you might consider is just looking at the portion of the word you want to replace, e.g.

<term><termid>oe</termid><termuc>œ</termuc></term>

which will replace all the above words, and won't touch the first letter of the word. That will also handle any other words with œ in them.
John Turnbull
Thunderstone Software
greer
Posts: 10
Joined: Mon Nov 01, 2010 12:49 pm

Case sensitive sandr?

Post by greer »

Thanks guys, the first suggestion hit the nail on the head.
Post Reply