'Angular Regex Split String 1x asd..... 2x asd
I am trying to split a string by [0-9]+ [xX] | [0-9]+[xX], string example:
10 x source 4 50° on booms (2 downstage left and right, 2 upstage left and right) 2x festoons (mentioned above) 4x 1kx Fresnel backlight in L712 4x SL 15/32 (3x L443, 4x R119) – all four of which are specifically focused specials 1x Edison bulb suspended from grid
I would like to break the text into seperate lines using a pipe in angular, to display like:
10 x source 4 50° on booms (2 downstage left and right, 2 upstage left and right)
2x festoons (mentioned above)
4x 1kx Fresnel backlight in L712
4x SL 15/32 (3x L443, 4x R119) – all four of which are specifically focused specials
1x Edison bulb suspended from grid
I have tried to use the following regex but it is including the next 1x in the regex.
/([0-9]+[xX] [a-zA-z].*)(?:([0-9]+[xX]))/gm
Output: 10x source 4 50° on booms (2 downstage left and right, 2 upstage left and right) 2x festoons (mentioned above) 4x 1kx Fresnel backlight in L712 4x SL 15/32 (3x L443, 4x R119) – all four of which are specifically focused specials 1x
I would also like to be able to add the option as mentioned in the first sentance to check on two scenarios.
- 1x asd....
- 1 x asd....
Then I will split the string using the regex in Angular.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
