views:

48

answers:

2

I would like to write a javascript plug in which can string manipulations something like substring, replace, trim and customized user functions.

Where from should i start to write (if there is no this kind of plug-in) ?

like: $("my string will be this").substr("will","would",{first});

or

$("my string will be this").replace("will","would",{fromLast,3});

+2  A: 

http://stilldesigning.com/dotstring/ ports prototype string functions to jQuery. Take a look at the code.

methodin
+1  A: 

You don't need JQuery - Javascript's own built-in string.replace() function uses Regex and is already far more powerful than the examples you suggested.

newstring = mystring.replace(/will/,'would');

(replacing specific instances of a word is harder, but achievable with regex)

Spudley