Microsoft
Software
Hardware
Network
Question : javascrip string parsing question
Suppose I have strings with below format:
Test 07/2010 (Product 10005)
Test 08/2010 (Product 10006)
In this kind of strings, ony the data field (07 and 2010 and 10005) are changed fields, other parts are fixed. How could I parse this kind of string to get value like:
month: 07
year: 2010
Product: 10005
BTW, for string not staring with "Test", then I do not want to parse it.
Many thanks.
Answer : javascrip string parsing question
if (string.match(/^Test/)) {
var month = string.replace(/^Test\ (\d+)\/\d+\ .*$/, '$1');
var year = string.replace(/^Test\ \d+\/(\d+)\ .*$/, '$1');
var Product = string.replace(/^.*Product
\ (\d+)\)$/, '$1');
}
Random Solutions
mailto hyperlink with multiple links on multiple lines
building a new server machine that has server 2003. need help
Block messages sent to recipients not listed in the Global Address List
Cisco 79xx Message Button
Getting Column Names from RowDataBound
Java Client Applet - Passing one boolean to another
Trouble getting Outlook 2007 to connect to Exchange 2010
Delphi Is there a simple way to Concat two Dynamic Arrays in to one Array?
add line spaces within a VBA email message
Bringing a Windows 2008 R2 DC into an Exisiting Windows 2003 domain