oops, drop that +

    oldString.replace(/[bad or dashable chars]/g,

so you get 1 char at a time,

On 3/7/07, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote:
> and while we're at it,
>
> you can use a function as the second parameter!
>
> oldString.replace(/[bad or dashable chars]+/g,
>                    function (str) {
>                       return (str.match(/^[dashable chars]$/) ? "-" : "")
>                    }
>                 )
>
> 1 command 1 replace!
>
> On 3/7/07, Matt Stith <[EMAIL PROTECTED]> wrote:
> > Quick tut:
> >
> > Just typing something out, eg, /abcd/ would replace anything that contained
> > the exact string "abcd", case sensative. If you do /[abcd]/, notice the
> > brackets, it will select the letter "a", the letter "b", etc. For ranges you
> > can do something like /[a-d]/, which would do the same as /[abcd]/. Remember
> > that regex is case sensative, unless you add an "i" flag to the expression,
> > like /[a-d]/i  , which would find "a-d", and "A-D". Also, it will only
> > replace the first instance, unless you add a "g" flag, so:
> >
> > "once upon a time".replace(/o/,'O');
> >  would make "Once upon a time", but:
> > "once upon a time".replace(/o/g,"O");
> > would make "Once upOn a time"
> >
> >
> >
> > On 3/7/07, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote:
> > > 1 command , 2 replaces
> > >
> > > var newString = oldString.replace(/X/,"-").replace(/Y/,"")
> > >
> > >
> > >
> > > On 3/7/07, Alexandre Plennevaux <[EMAIL PROTECTED] > wrote:
> > > >
> > > >
> > > > hello!
> > > >
> > > > I'm experimenting with regular expressions, and i would like to replace
> > in a
> > > > string some special characters by a "-" minus sign, and others by just
> > > > removing it.
> > > > Do i need ot make two regex.replace(), or is it possible to have both in
> > one
> > > > command?
> > > >
> > > > thank you very much for your time!
> > > >
> > > > Alexandre
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > >  Ce message Envoi est certifié sans virus connu.
> > > >  Analyse effectuée par AVG.
> > > >  Version: 7.5.447 / Base de données virus: 268.18.7/712 - Date:
> > 6/03/2007
> > > > 15:42
> > > >
> > > > _______________________________________________
> > > > jQuery mailing list
> > > > discuss@jquery.com
> > > > http://jquery.com/discuss/
> > > >
> > > >
> > >
> > >
> > > --
> > > Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
> > > _______________________________________________
> > > jQuery mailing list
> > > discuss@jquery.com
> > > http://jquery.com/discuss/
> > >
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > discuss@jquery.com
> > http://jquery.com/discuss/
> >
> >
>
>
> --
> Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
>


-- 
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to