Answers.Body: <p><a href="https://i.sstatic.net/IdX5U.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/IdX5U.gif" alt="enter image description here" /></a>
  Here's my updated way of doing it.</p>
  <p>A couple of points:</p>
  <ol>
  <li>This method will only work with fixed width fonts</li>
  <li>Make sure you have an even number of characters in your plain text layer.  Add a space on the end if you don't.</li>
  </ol>
  <p>Make two identical text layers. In my example, they are labelled &quot;AGCT text&quot; and &quot;plain text&quot;.</p>
  <p>In the &quot;ACGT text&quot; layer, put the following expression into the Source Text control:</p>
  <pre><code>n = 4; // how many pairs of characters (starting from zero, so 0 to 4 is 5 pairs, so 10 characters).
  letters = [&quot;A&quot;,&quot;T&quot;,&quot;C&quot;,&quot;G&quot;]; // array of possible characters to use
  str = &quot;&quot;; // string we will print
  
  for (i = 0; i &lt;= n; i++){  // start a loop, repeat it n times
  
      var m = Math.round(random(3)); // pick a number between 0 and 3
      j = letters[m]; // make a variable using one of the characters 
      str += (i &gt; 0 ? &quot;&quot; : &quot;&quot;) + j + j; // append that character to the string twice
  }
  
  str // print the string
  </code></pre>
  <p>Add a text animator to both layers.</p>
  <p>Set the opacity on both text animators to 0%.</p>
  <p>In the Advanced settings of the text animator, set the Shape to Square.</p>
  <p>Animate the &quot;plain text&quot; animator so that the &quot;Range Selector 1&quot; Start control is 0% at the beginning of the animation, and 100% at the end.  Make sure the &quot;Range Selector 1&quot; End control is set to 100% throughout.</p>
  <p>Now animate the &quot;ATCG text&quot; layer:</p>
  <p>Set the &quot;Range Selector 1&quot; Start and End controls to 0% at the beginning of the animation.  Set the End control to 100% at the end of the animation. Make sure the Start control is 0% throughout.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T19:10:10.593Z
Answers.Text: Thank you! I have to use Source Sans Pro Bold for the font, but it seems to work even though I'm not sure if it's fixed width. Sorry for the confusion, I've been told it should actually not be pairs, but instead just a random assortment of As, Cs, Gs, and Ts. I thought maybe getting rid of the "n=4" might do the trick, but that breaks the expression. Is there a way to do this?
Answers.UserDisplayName: Onion44
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T19:11:22.897Z
Answers.Text: Change the “j+j” bit to only one j
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T20:16:33.630Z
Answers.Text: Thanks @tomh! That did the trick. Like you said, the font needs to be fixed width so that the ATCG layer takes up the same amount of width as the plain layer. It's not completely clean the way I have it, but I think it will work. I'm curious, how did you get so good at expressions?
Answers.UserDisplayName: Onion44
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T20:18:23.360Z
Answers.Text: I'm not!  Googling around and trying out snippets of other people's code!  http://motionscript.com/ and  https://creativecow.net/forums/forum/adobe-after-effects-expressions/ are both v useful (and this site obvs)
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T20:29:51.297Z
Answers.Text: This is super helpful. I'll definitely be using these resources going forward. Thanks!
Answers.UserDisplayName: Onion44
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-15T13:06:03.630Z
Answers.LastActivityDate: 2022-03-17T09:10:01.847Z
Answers.LastEditDate: 2022-03-17T09:10:01.847Z
Answers.UserDisplayName: tomh
Body: <p>I'd like the bottom left text to do the same as the top right, but the randomized text should be limited to &quot;ATCG&quot; in pairs (e.g. &quot;AATTCCGG), instead of numbers. Is there a way to do this with expressions? Preserve Case &amp;  Digits seems to keep the random text to pairs, but I'm not sure how to make an expression so that the pairs are limited to As, Ts, Cs, and Gs. Thanks!
  <a href="https://i.sstatic.net/uvCcm.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/uvCcm.gif" alt="" /></a></p>
  <p><a href="https://i.sstatic.net/QGyqn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QGyqn.png" alt="preview and timeline" /></a></p>
  
Tags: <after-effects><after-effects-expressions>
Title: AE: Character Offset to Randomize Specific Pairs of Letters
UserDisplayName: Onion44
ThreadText: # AE: Character Offset to Randomize Specific Pairs of Letters
  
  (Asked by: username_0 on 2022-03-14)
  
  I'd like the bottom left text to do the same as the top right, but the randomized text should be limited to "ATCG" in pairs (e.g. "AATTCCGG), instead of numbers. Is there a way to do this with expressions? Preserve Case & Digits seems to keep the random text to pairs, but I'm not sure how to make an expression so that the pairs are limited to As, Ts, Cs, and Gs. Thanks!
  [![](https://i.sstatic.net/uvCcm.gif)](https://i.sstatic.net/uvCcm.gif)
  
  [![preview and timeline](https://i.sstatic.net/QGyqn.png)](https://i.sstatic.net/QGyqn.png)
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-03-15. Score: 1
  
  [![enter image description here](https://i.sstatic.net/IdX5U.gif)](https://i.sstatic.net/IdX5U.gif)
  Here's my updated way of doing it.
  
  A couple of points:
  
  1. This method will only work with fixed width fonts
  2. Make sure you have an even number of characters in your plain text layer. Add a space on the end if you don't.
  
  Make two identical text layers. In my example, they are labelled "AGCT text" and "plain text".
  
  In the "ACGT text" layer, put the following expression into the Source Text control:
  
  ```
  n = 4; // how many pairs of characters (starting from zero, so 0 to 4 is 5 pairs, so 10 characters).
  letters = ["A","T","C","G"]; // array of possible characters to use
  str = ""; // string we will print
  
  for (i = 0; i <= n; i++){  // start a loop, repeat it n times
  
      var m = Math.round(random(3)); // pick a number between 0 and 3
      j = letters[m]; // make a variable using one of the characters 
      str += (i > 0 ? "" : "") + j + j; // append that character to the string twice
  }
  
  str // print the string
  
  ```
  
  Add a text animator to both layers.
  
  Set the opacity on both text animators to 0%.
  
  In the Advanced settings of the text animator, set the Shape to Square.
  
  Animate the "plain text" animator so that the "Range Selector 1" Start control is 0% at the beginning of the animation, and 100% at the end. Make sure the "Range Selector 1" End control is set to 100% throughout.
  
  Now animate the "ATCG text" layer:
  
  Set the "Range Selector 1" Start and End controls to 0% at the beginning of the animation. Set the End control to 100% at the end of the animation. Make sure the Start control is 0% throughout.
  
  > **Comments:**
  > **username_0**: Thank you! I have to use Source Sans Pro Bold for the font, but it seems to work even though I'm not sure if it's fixed width. Sorry for the confusion, I've been told it should actually not be pairs, but instead just a random assortment of As, Cs, Gs, and Ts. I thought maybe getting rid of the "n=4" might do the trick, but that breaks the expression. Is there a way to do this?  
  > **username_1**: Change the “j+j” bit to only one j  
  > **username_0**: Thanks @username_1! That did the trick. Like you said, the font needs to be fixed width so that the ATCG layer takes up the same amount of width as the plain layer. It's not completely clean the way I have it, but I think it will work. I'm curious, how did you get so good at expressions?  
  > **username_1**: I'm not!  Googling around and trying out snippets of other people's code!  http://motionscript.com/ and  https://creativecow.net/forums/forum/adobe-after-effects-expressions/ are both v useful (and this site obvs)  
  > **username_0**: This is super helpful. I'll definitely be using these resources going forward. Thanks!  
  
  ---
  
  