rgarimella
asked on
String SubString Manipulation
Hi Folks,
I have a javascript variable which has a value of "ab_03_01_0010.htm"
I need to extract 03 out of the string and put it in another var. The naming convention will be the same always.
var stringVal = "ab_03_01_0010.htm" ;
I need the solution so that I get
var subStringVal = "03"
Thanks
RG
I have a javascript variable which has a value of "ab_03_01_0010.htm"
I need to extract 03 out of the string and put it in another var. The naming convention will be the same always.
var stringVal = "ab_03_01_0010.htm" ;
I need the solution so that I get
var subStringVal = "03"
Thanks
RG
tested it, works for me. The construct [^_]+ is used in the regular expression to capture anything NOT containing an underscore, which is necessary to get to the second "element" containing your "03" (which is caught the same way).
ASKER
sorry there was a bug in my code
var stringVal = "ab_03_01_0010.htm" ;
How do i capture
var subStringVal = "03_01"
The filename convention will be the same
var stringVal = "ab_03_01_0010.htm" ;
How do i capture
var subStringVal = "03_01"
The filename convention will be the same
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Much Appreciated for your help
RG
RG
You're welcome, glad I could be of some help :)
-- Abel --
-- Abel --
var subStringVal = stringVal.replace(/^[^_]+_