On May 4, 12:59 pm, Erich93063 <erich93...@gmail.com> wrote:
> On May 4, 12:48 pm, "scripts.contact" <scripts.cont...@gmail.com>
> wrote:
>
> > Erich93063 wrote:
> > > Hi sorry this is probably the easiest answer ever but how do I replace
> > > all punctuation in a variable. I also in the same function want to
> > > replace all spaces with underscores.
>
> > try:
>
> > variable=variable.replace(/[^\w-]/g,'').replace(/\s/g,'_')
>
> Thanks.
>
> Ok so I tried that and it did replace the punctuation but the spaces
> just got removed instead of being replaced with "_"
After messing around with it, this ended up working:
cboModel.value.replace(/ /g,'_').replace(/[^\w-]/g,'')
THANKS
|