# Please help with regular expression in javascript

**URL:** <https://forum.kirupa.com/t/please-help-with-regular-expression-in-javascript/186891>\
**Category:** Uncategorized\
**Created:** [April 25, 2006, 8:38am UTC](https://forum.kirupa.com/t/please-help-with-regular-expression-in-javascript/186891 "2006-04-25T08:38:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 25, 2006, 8:38am UTC](https://forum.kirupa.com/t/please-help-with-regular-expression-in-javascript/186891/1 "2006-04-25T08:38:31Z")

</div>

Hi there,  
I have written a regular expression to convert ‘&’ into ‘and’. however it only changes the first occurance of ‘&’ not all of them.

this is my first time using reg ex so I would love any help whatsoever

NB: this is a JavaScript Function

```php

function tidyD(h){ 
    h = h.replace(/(\/?)&amp;([^>]*)/gi, "$1and$2"); 
    return h;
}

```

eg:

[COLOR=DarkSlateBlue]apples & oranges & pears [/COLOR]  
would become  
[COLOR=DarkSlateBlue]apples and oranges & pears [/COLOR]  
8-]

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 25, 2006, 10:34am UTC](https://forum.kirupa.com/t/please-help-with-regular-expression-in-javascript/186891/2 "2006-04-25T10:34:40Z")

</div>

found the answer…

here it is

h = h.replace(/&/g, ‘and’);

this searches an entire string and converts all occurances of ‘&amp’ with ‘and’

any ideas on how to change the **é** character to **e**?

---

<div class="post-metadata">

**Author:** ![bootiteq](https://avatars.discourse-cdn.com/v4/letter/b/eb9ed0/32.png) [@bootiteq](https://forum.kirupa.com/u/bootiteq)\
**Post date:** [April 25, 2006, 10:58am UTC](https://forum.kirupa.com/t/please-help-with-regular-expression-in-javascript/186891/3 "2006-04-25T10:58:55Z")

</div>

found the answer to that too

h = h.replace(/\u00E9/g, ‘e’);

\u00E9 stands for the unicode number.

his searches an entire string and converts all occurances of **é** to **e**

feel like im having a conversation with myself :pir:
