Hi
What string function to be used in jquery +dot.net
In this string
"Saree $20"
"Pant $50"
I want to take the $ amount alone that is 20 and 50..
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pravin MoreRank #1,419 · 1.2K reputationPosted Dec 1, 2011, 8:29 PM EST
var strval="Saree $20";
var tempstr= strval.substr ( strval.indexOf ( '$' ) + 1 );
you will get 20 here in tempstr.
n you can parse it to number if you want.
Thanks,
Pravin.
Anuja PawarRank #1,404 · 1.2K reputationPosted Dec 1, 2011, 8:57 PM EST
SairamRank #5,130 · 310 reputationPosted Dec 1, 2011, 9:15 PM EST
input may be like this
saree $20
saree
saree 100
if $ present in the string then have to take dollar amount else no need
Pravin MoreRank #1,419 · 1.2K reputationPosted Dec 1, 2011, 9:29 PM EST
var tempstr= strval.substr ( strval.indexOf ( '$' ) + 1 );
this will work i think, have you tried?
SairamRank #5,130 · 310 reputationPosted Dec 1, 2011, 9:35 PM EST
Done as below
if (s.indexOf("$") > -1)