Re: [OT] Jquery Remove Trailing "&" From String

View: New views
3 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: [OT] Jquery Remove Trailing "&" From String

by Brad Lindsay-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Jul 6, 2009, at 2:23 PM, Israel Thompson wrote:
> Sorry, for posting here.. something seems to be wrong with my post  
> being
> accepted in the Jquery list...
>
> What's the easiest way to remove the trailing "&" from a string in  
> Jquery?

If the string is a JavaScript variable named str, this code should work:

        str.replace(/&$/,"");

-Brad

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: [OT] Jquery Remove Trailing "&" From String

by Brad Lindsay-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jul 6, 2009, at 2:30 PM, Brad Lindsay wrote:

> On Jul 6, 2009, at 2:23 PM, Israel Thompson wrote:
>> Sorry, for posting here.. something seems to be wrong with my post  
>> being
>> accepted in the Jquery list...
>>
>> What's the easiest way to remove the trailing "&" from a string in  
>> Jquery?
>
> If the string is a JavaScript variable named str, this code should  
> work:
>
> str.replace(/&$/,"");
>
> -Brad


If you want to replace all trailing "&", for example "test&&&&"  
becomes "test", edit the regular expression so that the code looks  
like this:
        str.replace(/&+$/, "");

-Brad

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/



Re: [OT] Jquery Remove Trailing "&" From String

by Israel Thompson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks, that works!

Israel


Brad Lindsay-2 wrote:

> If the string is a JavaScript variable named str, this code should  
> work:
>
> str.replace(/&$/,"");
>
> -Brad


If you want to replace all trailing "&", for example "test&&&&"  
becomes "test", edit the regular expression so that the code looks  
like this:
        str.replace(/&+$/, "");

-Brad