# Can we Substitue numbers for letters and back?

**URL:** <https://community.wolfram.com/t/can-we-substitue-numbers-for-letters-and-back/7781>\
**Category:** Questions\
**Tags:** computational-linguistics\
**Created:** [January 29, 2016, 10:18am UTC](https://community.wolfram.com/t/can-we-substitue-numbers-for-letters-and-back/7781 "2016-01-29T10:18:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul2cleary](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@paul2cleary](https://community.wolfram.com/u/paul2cleary)\
**Post date:** [January 29, 2016, 10:18am UTC](https://community.wolfram.com/t/can-we-substitue-numbers-for-letters-and-back/7781/1 "2016-01-29T10:18:39Z")

</div>

Lets say I have a small list of numbers converted to digits

p={{1,3,9,8,5,4,2,7,6},{1,5,2,8,4,3,7,6,9},{1,5,7,3,2,6,8,4,9}}

and I also have 2 Words say txt2={INTRODUCE,REDUCTION}

I want to map the first set of digits to the first word so

```
Thread[Characters[txt2[[1]]] -> p[[1]]]

```

gives me

```
 {I->1,N->3,T->9,R->8,O->5,D->4,U->2,C->7,E->6}

```

I now wish to map those back to see what REDUCTION in digits would be i.e.

REDUCTION = 864279153

and repeat for the other digits sets in list p

The Thread function seems to go part way but can’t see how to reverse the process any help would be much appreciated.

Paul.

---

<div class="post-metadata">

**Author:** ![Vitaliyk](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/vitaliyk/32/45591_2.png) [@Vitaliyk](https://community.wolfram.com/u/Vitaliyk)\
**Post date:** [January 29, 2016, 10:32am UTC](https://community.wolfram.com/t/can-we-substitue-numbers-for-letters-and-back/7781/2 "2016-01-29T10:32:36Z")

</div>

`ReplaceAll` or `/.` ?

```
p = {{1, 3, 9, 8, 5, 4, 2, 7, 6}, {1, 5, 2, 8, 4, 3, 7, 6, 9}, {1, 5, 7, 3, 2, 6, 8, 4, 9}};
txt = {"INTRODUCE", "REDUCTION"};
FromDigits[Characters[txt[[2]]] /. Thread[Characters[txt[[1]]] -> p[[1]]]]
(*864279153*)

```

Another way is `StringReplace` but that outputs number as string:

```
StringReplace["REDUCTION", Thread[Characters[txt[[1]]] -> ToString /@ p[[1]]]]
(*"864279153"*)

```

---

<div class="post-metadata">

**Author:** ![paul2cleary](https://avatars.discourse-cdn.com/v4/letter/p/22d042/32.png) [@paul2cleary](https://community.wolfram.com/u/paul2cleary)\
**Post date:** [January 29, 2016, 10:39am UTC](https://community.wolfram.com/t/can-we-substitue-numbers-for-letters-and-back/7781/3 "2016-01-29T10:39:54Z")

</div>

Excellent, thank you Vitaliy, already amended to account for the list.
