[jQuery] Re: trim string

2009-09-15 Thread teknoFX

You could easily just do the following:

cat=["com12", "com1", "cop233", "com1.1", "sap-12-1"];
cat = $.map(cat, function(a){ return a.replace(/[\d\.\-]/g, ""); });

Good Luck!


[jQuery] Re: trim string

2009-09-14 Thread bjorsq


Try this:

  function filterArray(arr)
  {
var newArr = [];
for (var i = 0; i < arr.length; i++) {
  newArr.push(arr[i].replace(/[0-9\-.]/g, ''));
}
return newArr;
  }



runrunforest wrote:
> 
> 
> Hi,
> 
> I have an array like this cat=(com12, com1, cop233, com1.1, sap-12-1)
> 
> I want to take out all the numbers and "." and "-" signs
> 
> the desire result is cat=(com, com, cop, sap)
> 
> how can i do that please ?
> 
> 

-- 
View this message in context: 
http://www.nabble.com/trim-string-tp25433275s27240p25436583.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: trim string

2009-09-14 Thread sqwerl

It would be best to use a regular expression.

On Sep 14, 5:37 am, "Mohd.Tareq"  wrote:
> Try object.substring('.',' ');
>
> On Mon, Sep 14, 2009 at 3:40 PM, runrunforest  wrote:
>
> > Hi,
>
> > I have an array like this cat=(com12, com1, cop233, com1.1, sap-12-1)
>
> > I want to take out all the numbers and "." and "-" signs
>
> > the desire result is cat=(com, com, cop, sap)
>
> > how can i do that please ?
>
> --
>        Regard
> Mohammad.Tareque


[jQuery] Re: trim string

2009-09-14 Thread Mohd.Tareq
Try object.substring('.',' ');

On Mon, Sep 14, 2009 at 3:40 PM, runrunforest  wrote:

>
> Hi,
>
> I have an array like this cat=(com12, com1, cop233, com1.1, sap-12-1)
>
> I want to take out all the numbers and "." and "-" signs
>
> the desire result is cat=(com, com, cop, sap)
>
> how can i do that please ?




-- 
   Regard
Mohammad.Tareque


[jQuery] Re: $.trim(string) or string.trim()

2009-04-02 Thread MorningZ

"will jQuery add it in the future"

that doesn't really make sense, as it's a String object thing, not
really a jQuery object thing

and it's super easy to add with one single line

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,
''); };

bam

var s = "  i am string with whitespace";

s.trim() >   "i am a string with whitespace"



James wrote:
> jQuery does have a trim function:
> http://docs.jquery.com/Utilities/jQuery.trim
> Although it's not in the syntax of "string".trim().
>
> return jQuery != MooTools;
>
> On Apr 1, 5:46 pm, yifang  wrote:
> > mootools support syntax like this "string".trim()
> > will jquery support such features in the future?
> > thanks.


[jQuery] Re: $.trim(string) or string.trim()

2009-04-02 Thread James

jQuery does have a trim function:
http://docs.jquery.com/Utilities/jQuery.trim
Although it's not in the syntax of "string".trim().

return jQuery != MooTools;

On Apr 1, 5:46 pm, yifang  wrote:
> mootools support syntax like this "string".trim()
> will jquery support such features in the future?
> thanks.