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
SQL SERVER 2008 - Use a Variable as a Column Name
query result seems to change number to text
Sony Bravia screen burn in
Force MsgBox popup when users are logged into XP
Move Mailbox from Exchange 2003 to Exchange 2010
Logon script that will copy the registry from a server share to local machine, then log user off
Setting up mail server on Ubuntu 8.04
How to turn off or alter amount of space used by System Restore and Shadow Copy in Vista?
List Of Different ERP Modules And Information About ERP
VMX fto multiple machines