javascript - regex '\s+-\s*|\s*-\s+' does not work correctly -


I am parsing a large list with a node. Js app and this code is

  SizeCode = dbfr.CN_DESC.split ('\ s + - \ s * | \ s * - \ s +')   

This works as it seems it returns Why Women's Cc Croppy Top T-Shirt - Mellen Gray - S [[Female CC Cropped Top T-Shirt - Melon Gray - M '] [' Female CC Cropped Top T-shirt - Melon Gray - L '] [' Female 's CC Top Top-T-Shirt - White - S] [' Female C 'Cropped Top T-Shirt - White - M'] ['Women' 's CC Cropper Top T-Shirt - White - L'] ['Women' s CC short cut rear back tunic West - White - M '] [' Female SCL Low Race Rack Back Tunic West - White - L ']

Where I just

  sizeCode = dbfr.CN_DESC.split ( '-')   use 

works correctly, although I have the issue that in some instances, I may have a different situation for '-' dash character For example:

  ['Women' sc Top Top Two-Shirt - White - L '] [' Women 's CC short cut rear back tunic West-White - M'] ['Women' s CC short cut rear back tunic waste - White-L ']   

But for example I do not want to divide the T-shirt.

Any advice is very commendable

You use regex delimiter in your regex Will be:

  sizeCode = dbfr.CN_DESC.split (/ \ s + - \ s * | \ * * - \ s + / g)   



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -