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
how to integrate live video chat room in to my site
Add time mark (:) in data
Can't hide GridView Delete button programmatically -- help!
WAMP will not restart on WINDOWS 2003 Server
Can you subnet 1 public address or only a Class A, B or C network?
Windows server 2008 64bti Domain Controller
SQL Single quote messing up query results
Stop Error 0x0000007e on Server 2003
ISAPI Filter 'C:\Windows\Microsoft.NET\
Framework\
v4.0.30319
\aspnet_fi
lter.dll' could not be loaded due to a configuration problem
quickbooks on DFS