Parse my Esperanto!

QuadR, 65 bytes


Try it online!

.x replace any char followed by "x" with

3::⍵M upon indexing error, return the match unmodified
 now try:
'ĉĝĥĵŝŭĈĜĤĴŜŬ'[] index into this string with
  ⍵M the match's
   first letter's
  'cghjsuCGHJSU' in this string

This is equivalent to the Dyalog APL tacit function:


Retina, 27 bytes


Try it online!

This program is composed by two transliterations. Due to having combining characters in the code this doesn't render too well, the first line should actually look similar to iT`x`^`[cghjs]x, where ^ stands for the circumflex accent combining character. What this is saying is that it should Transliterate (ignoring case) all the xs in the input into a ^, whenever they are following any letter in [cghjs].

Note: TIO incorrectly measures this code as 25 bytes. Actually, this Retina program uses UTF-8 encoding (other programs can use UTF-32 or ISO 8859-1) and the two combining characters present cost 2 bytes each.

C,  173  154 bytes

Thanks to @Colera Su for saving 17 bytes!


Try it online!


    // The outer loop and an array of characters that are modified by a trailing 'x'.
    // The array/string is used for getting the index for the accented character later.
    for (char*l="cghjsuCGHJSU";

                                // Store the current character of the input string in 'p'.
                                // If it is '\0', the loop terminates.

                                      // The last statement in the loop.
                                      // If 'c==-1', it outputs the char stored in 'p'. 

        // Store the character following 'p' in 'c' and increment the string pointer.
        for(c=*++s, i=0;

                        // If 'c' is not the letter 'x', the inner loop terminates
                        // immediately. Otherwise it loops through the characters of
                        // string 'l'.
                        c=='x'&&l[i]; ++i)

            // If the character stored in 'p' is found inside the string 'l'...
            l[i]-p ||

                      // ...then print the accented character corresponding to 'p'.
                      // 'i' is the index of 'p' in 'l', and, because the characters
                      // with accents are two bytes each, the index is multiplied by 2.

                      // Finally set 'c' to -1 so that the non-accented character doesn't
                      // get printed too, and increment the string pointer so that the
                      // letter 'x' doesn't get printed either.
                                                    c=-1, ++s);